Skip to content

Commit 41a439d

Browse files
committed
Added context managers
1 parent b6f6fba commit 41a439d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Tests/test_file_ppm.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def test_not_ppm(tmp_path):
5656
f.write(b"PyInvalid")
5757

5858
with pytest.raises(UnidentifiedImageError):
59-
Image.open(path)
59+
with Image.open(path):
60+
pass
6061

6162

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

7677
with pytest.raises(ValueError):
77-
Image.open(path)
78+
with Image.open(path):
79+
pass
7880

7981

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

8587
with pytest.raises(ValueError):
86-
Image.open(path)
88+
with Image.open(path):
89+
pass
8790

8891

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

9497
with pytest.raises(ValueError):
95-
Image.open(path)
98+
with Image.open(path):
99+
pass
96100

97101

98102
def test_truncated_file(tmp_path):

0 commit comments

Comments
 (0)