Skip to content

Commit

Permalink
Merge pull request #222 from ConorMacBride/fix-unclosed-test-files
Browse files Browse the repository at this point in the history
Fix unclosed test files
  • Loading branch information
ConorMacBride authored Feb 14, 2024
2 parents 3bd3703 + a9713dc commit 2b1b8d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions tests/test_default_tolerance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
@pytest.fixture(scope="module")
def baseline_image(tmp_path_factory):
path = Path(__file__).parent / "baseline" / "2.0.x" / f"{TEST_NAME}.png"
image = Image.open(path)
draw = ImageDraw.Draw(image)
draw.rectangle(((0, 0), (100, 100)), fill="red")
output = tmp_path_factory.mktemp("data") / f"{TEST_NAME}.png"
image.save(output)
with Image.open(path) as image:
draw = ImageDraw.Draw(image)
draw.rectangle(((0, 0), (100, 100)), fill="red")
output = tmp_path_factory.mktemp("data") / f"{TEST_NAME}.png"
image.save(output)
return output


Expand Down
3 changes: 2 additions & 1 deletion tests/test_deterministic.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def test_mpl():
assert key_in_file

else: # "eps" or "png"
actual_metadata = Image.open(str(baseline_image)).info
with Image.open(str(baseline_image)) as image:
actual_metadata = image.info
for k, expected in deterministic_metadata.items():
actual = actual_metadata.get(k, None)
if success_expected: # metadata keys should not be in the file
Expand Down

0 comments on commit 2b1b8d7

Please sign in to comment.