Skip to content

Commit

Permalink
Added context managers
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Mar 21, 2021
1 parent b6f6fba commit b9c841c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Tests/test_file_ppm.py
Expand Up @@ -56,7 +56,8 @@ def test_not_ppm(tmp_path):
f.write(b"PyInvalid")

with pytest.raises(UnidentifiedImageError):
Image.open(path)
with Image.open(path):
pass


def test_header_with_comments(tmp_path):
Expand All @@ -74,7 +75,8 @@ def test_nondecimal_header(tmp_path):
f.write(b"P6\n128\x00")

with pytest.raises(ValueError):
Image.open(path)
with Image.open(path):
pass


def test_token_too_long(tmp_path):
Expand All @@ -83,7 +85,8 @@ def test_token_too_long(tmp_path):
f.write(b"P6\n 0123456789")

with pytest.raises(ValueError):
Image.open(path)
with Image.open(path):
pass


def test_too_many_colors(tmp_path):
Expand All @@ -92,7 +95,8 @@ def test_too_many_colors(tmp_path):
f.write(b"P6\n1 1\n1000\n")

with pytest.raises(ValueError):
Image.open(path)
with Image.open(path):
pass


def test_truncated_file(tmp_path):
Expand All @@ -101,7 +105,8 @@ def test_truncated_file(tmp_path):
f.write("P6")

with pytest.raises(ValueError):
Image.open(path)
with Image.open(path):
pass


def test_neg_ppm():
Expand All @@ -111,7 +116,8 @@ def test_neg_ppm():
# sizes.

with pytest.raises(OSError):
Image.open("Tests/images/negative_size.ppm")
with Image.open("Tests/images/negative_size.ppm"):
pass


def test_mimetypes(tmp_path):
Expand Down

0 comments on commit b9c841c

Please sign in to comment.