tests/stages: write out produced metadata

When the expected metadata does not match the produced metadata,
write the latter to `/tmp` for closer inspection; additionally
this should help update the metadata file in case the changes
are expected.
This commit is contained in:
Christian Kellner 2021-03-16 23:39:18 +00:00 committed by Tom Gundersen
parent 5de2d3f96b
commit b4f58ccc72

View file

@ -133,7 +133,10 @@ class TestStages(test.TestBase):
diff = difflib.ndiff(pprint.pformat(have).splitlines(),
pprint.pformat(want).splitlines())
txt = "\n".join(diff)
self.fail(f"metadata for {stageid} differs:\n{txt}")
path = f"/tmp/osbuild.metadata.{stageid}.json"
with open(path, "w") as f:
json.dump(have, f, indent=2)
self.fail(f"metadata for {stageid} differs:\n{txt}\n{path}")
@classmethod
def setUpClass(cls):