Skip to content

Commit

Permalink
Parametrized test
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 28, 2022
1 parent 6da4169 commit 0da8e43
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Tests/test_file_tiff_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,21 @@ def test_iptc(tmp_path):
im.save(out)


def test_writing_other_types_to_ascii(tmp_path):
im = hopper()
@pytest.mark.parametrize("value, expected", ((b"test", "test"), (1, "1")))
def test_writing_other_types_to_ascii(value, expected, tmp_path):
info = TiffImagePlugin.ImageFileDirectory_v2()

tag = TiffTags.TAGS_V2[271]
assert tag.type == TiffTags.ASCII

out = str(tmp_path / "temp.tiff")
for (value, expected) in {b"test": "test", 1: "1"}.items():
info[271] = value
info[271] = value

im.save(out, tiffinfo=info)
im = hopper()
out = str(tmp_path / "temp.tiff")
im.save(out, tiffinfo=info)

with Image.open(out) as reloaded:
assert reloaded.tag_v2[271] == expected
with Image.open(out) as reloaded:
assert reloaded.tag_v2[271] == expected


def test_writing_int_to_bytes(tmp_path):
Expand Down

0 comments on commit 0da8e43

Please sign in to comment.