mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Added context managers
This commit is contained in:
parent
be97a851a8
commit
7aa7d850ee
|
@ -115,8 +115,9 @@ def test_plain_pbm_truncated_data(tmp_path):
|
|||
with open(path, "wb") as f:
|
||||
f.write(b"P1\n128 128\n")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
Image.open(path).load()
|
||||
with Image.open(path) as im:
|
||||
with pytest.raises(ValueError):
|
||||
im.load()
|
||||
|
||||
|
||||
def test_plain_pbm_invalid_data(tmp_path):
|
||||
|
@ -124,8 +125,9 @@ def test_plain_pbm_invalid_data(tmp_path):
|
|||
with open(path, "wb") as f:
|
||||
f.write(b"P1\n128 128\n1009")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
Image.open(path).load()
|
||||
with Image.open(path) as im:
|
||||
with pytest.raises(ValueError):
|
||||
im.load()
|
||||
|
||||
|
||||
def test_plain_ppm_data_with_comments(tmp_path):
|
||||
|
@ -147,8 +149,9 @@ def test_plain_ppm_truncated_data(tmp_path):
|
|||
with open(path, "wb") as f:
|
||||
f.write(b"P3\n128 128\n255\n")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
Image.open(path).load()
|
||||
with Image.open(path) as im:
|
||||
with pytest.raises(ValueError):
|
||||
im.load()
|
||||
|
||||
|
||||
def test_plain_ppm_invalid_data(tmp_path):
|
||||
|
@ -156,8 +159,9 @@ def test_plain_ppm_invalid_data(tmp_path):
|
|||
with open(path, "wb") as f:
|
||||
f.write(b"P3\n128 128\n255\n100A")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
Image.open(path).load()
|
||||
with Image.open(path) as im:
|
||||
with pytest.raises(ValueError):
|
||||
im.load()
|
||||
|
||||
|
||||
def test_plain_ppm_half_token_too_long(tmp_path):
|
||||
|
@ -165,8 +169,9 @@ def test_plain_ppm_half_token_too_long(tmp_path):
|
|||
with open(path, "wb") as f:
|
||||
f.write(b"P3\n128 128\n255\n012345678910")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
Image.open(path).load()
|
||||
with Image.open(path) as im:
|
||||
with pytest.raises(ValueError):
|
||||
im.load()
|
||||
|
||||
|
||||
def test_plain_ppm_token_too_long(tmp_path):
|
||||
|
@ -174,8 +179,9 @@ def test_plain_ppm_token_too_long(tmp_path):
|
|||
with open(path, "wb") as f:
|
||||
f.write(b"P3\n128 128\n255\n012345678910 0")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
Image.open(path).load()
|
||||
with Image.open(path) as im:
|
||||
with pytest.raises(ValueError):
|
||||
im.load()
|
||||
|
||||
|
||||
def test_plain_ppm_value_too_large(tmp_path):
|
||||
|
@ -183,8 +189,9 @@ def test_plain_ppm_value_too_large(tmp_path):
|
|||
with open(path, "wb") as f:
|
||||
f.write(b"P3\n128 128\n255\n256")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
Image.open(path).load()
|
||||
with Image.open(path) as im:
|
||||
with pytest.raises(ValueError):
|
||||
im.load()
|
||||
|
||||
|
||||
def test_magic(tmp_path):
|
||||
|
|
Loading…
Reference in New Issue
Block a user