Added context managers

This commit is contained in:
Andrew Murray 2021-08-24 23:43:38 +10:00 committed by GitHub
parent 0f11d22cce
commit 1b397751ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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")

View File

@ -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)