From 1b397751ec35f6f2a64a73dd7cec4ccd4a04bb62 Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Tue, 24 Aug 2021 23:43:38 +1000 Subject: [PATCH] Added context managers --- Tests/test_file_jpeg.py | 4 ++-- Tests/test_file_ppm.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index da78e4911..5bd16e356 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -895,8 +895,8 @@ class TestFileJpeg: if buffer: mystdout = mystdout.buffer - reloaded = Image.open(mystdout) - assert_image_equal(reloaded, im_roundtrip) + with Image.open(mystdout) as reloaded: + assert_image_equal(reloaded, im_roundtrip) @pytest.mark.skipif(not is_win32(), reason="Windows only") diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index 07c9bda84..ad36319db 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -108,5 +108,5 @@ def test_save_stdout(buffer): if buffer: mystdout = mystdout.buffer - reloaded = Image.open(mystdout) - assert_image_equal_tofile(reloaded, TEST_FILE) + with Image.open(mystdout) as reloaded: + assert_image_equal_tofile(reloaded, TEST_FILE)