Skip to content

Commit 5b2c7c7

Browse files
adamtheturtleclaude
andcommitted
Assert format-specific content in VuMark tests
Check magic bytes/prefix for each format (PNG, SVG, PDF) rather than just asserting non-empty bytes are returned. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b4e4d23 commit 5b2c7c7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/test_vws.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -737,15 +737,20 @@ class TestGenerateVumarkInstance:
737737

738738
@staticmethod
739739
@pytest.mark.parametrize(
740-
argnames="accept",
741-
argvalues=list(VuMarkAccept),
740+
argnames=("accept", "expected_prefix"),
741+
argvalues=[
742+
pytest.param(VuMarkAccept.PNG, b"\x89PNG\r\n\x1a\n", id="png"),
743+
pytest.param(VuMarkAccept.SVG, b"<", id="svg"),
744+
pytest.param(VuMarkAccept.PDF, b"%PDF", id="pdf"),
745+
],
742746
)
743747
def test_generate_vumark_instance(
744748
vws_client: VWS,
745749
high_quality_image: io.BytesIO,
746750
accept: VuMarkAccept,
751+
expected_prefix: bytes,
747752
) -> None:
748-
"""Bytes are returned when generating a VuMark instance."""
753+
"""The returned bytes match the requested format."""
749754
target_id = vws_client.add_target(
750755
name="x",
751756
width=1,
@@ -759,8 +764,7 @@ def test_generate_vumark_instance(
759764
instance_id="12345",
760765
accept=accept,
761766
)
762-
assert isinstance(result, bytes)
763-
assert len(result) > 0
767+
assert result.startswith(expected_prefix)
764768

765769
@staticmethod
766770
def test_generate_vumark_default_accept(
@@ -780,5 +784,4 @@ def test_generate_vumark_default_accept(
780784
target_id=target_id,
781785
instance_id="12345",
782786
)
783-
assert isinstance(result, bytes)
784-
assert len(result) > 0
787+
assert result.startswith(b"\x89PNG\r\n\x1a\n")

0 commit comments

Comments
 (0)