diff --git a/Makefile b/Makefile index 58fbb7c..f8b3307 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ fix: env/pyvenv.cfg PHONY: test-python-tuf test-python-tuf: dev - ./env/bin/pytest tuf_conformance \ + ./env/bin/pytest -v tuf_conformance \ --entrypoint "./env/bin/python ./clients/python-tuf/python_tuf.py" \ --repository-dump-dir $(DUMP_DIR) @echo Repository dump in $(DUMP_DIR) @@ -60,7 +60,7 @@ test-python-tuf: dev PHONY: test-go-tuf test-go-tuf: dev build-go-tuf - ./env/bin/pytest tuf_conformance \ + ./env/bin/pytest -v tuf_conformance \ --entrypoint "./clients/go-tuf/go-tuf" \ --repository-dump-dir $(DUMP_DIR) @echo Repository dump in $(DUMP_DIR) diff --git a/tuf_conformance/__init__.py b/tuf_conformance/__init__.py index 9aa3f90..b375329 100644 --- a/tuf_conformance/__init__.py +++ b/tuf_conformance/__init__.py @@ -1 +1,6 @@ +import pytest + __version__ = "2.1.0" + +# register pytest asserts before the imports happen in conftest.py +pytest.register_assert_rewrite("tuf_conformance.client_runner") diff --git a/tuf_conformance/client_runner.py b/tuf_conformance/client_runner.py index c81aaee..235bf06 100644 --- a/tuf_conformance/client_runner.py +++ b/tuf_conformance/client_runner.py @@ -5,6 +5,7 @@ from tuf.api.exceptions import StorageError from tuf.api.metadata import Metadata +from tuf.api.serialization.json import JSONSerializer from tuf_conformance.metadata import MetadataTest from tuf_conformance.simulator_server import ( @@ -130,13 +131,8 @@ def assert_metadata(self, role: str, expected_bytes: bytes | None) -> None: try: trusted = MetadataTest.from_file( os.path.join(self.metadata_dir, f"{role}.json") - ) + ).to_bytes(JSONSerializer()) except StorageError: trusted = None - if expected_bytes is not None: - expected = Metadata.from_bytes(expected_bytes) - else: - expected = None - - assert trusted == expected, f"Unexpected trusted role {role} content" + assert trusted == expected_bytes, f"Unexpected trusted role {role} content"