diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index c245a5a9bcb..958e2749f61 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -873,8 +873,8 @@ def test_lzma(self, capfd: pytest.CaptureFixture[str]) -> None: assert im.mode == "RGB" assert im.size == (128, 128) assert im.format == "TIFF" - im2 = hopper() - assert_image_similar(im, im2, 5) + with hopper() as im2: + assert_image_similar(im, im2, 5) except OSError: captured = capfd.readouterr() if "LZMA compression support is not configured" in captured.err: