Moved getvalue asserts outside of image context managers

This commit is contained in:
Andrew Murray 2021-05-27 18:42:07 +10:00 committed by Hugo van Kemenade
parent 07be0d26ba
commit c3e0fd1a7a

View File

@ -269,10 +269,10 @@ def test_mct():
for val in (0, 1): for val in (0, 1):
out = BytesIO() out = BytesIO()
test_card.save(out, "JPEG2000", mct=val, no_jp2=True) test_card.save(out, "JPEG2000", mct=val, no_jp2=True)
out.seek(0)
assert out.getvalue()[59] == val
with Image.open(out) as im: with Image.open(out) as im:
assert_image_similar(im, test_card, 1.0e-3) assert_image_similar(im, test_card, 1.0e-3)
assert out.getvalue()[59] == val
# Single component should have MCT disabled # Single component should have MCT disabled
for val in (0, 1): for val in (0, 1):
@ -280,10 +280,9 @@ def test_mct():
with Image.open("Tests/images/16bit.cropped.jp2") as jp2: with Image.open("Tests/images/16bit.cropped.jp2") as jp2:
jp2.save(out, "JPEG2000", mct=val, no_jp2=True) jp2.save(out, "JPEG2000", mct=val, no_jp2=True)
out.seek(0) assert out.getvalue()[53] == 0
with Image.open(out) as im: with Image.open(out) as im:
assert_image_similar(im, jp2, 1.0e-3) assert_image_similar(im, jp2, 1.0e-3)
assert out.getvalue()[53] == 0
def test_rgba(): def test_rgba():