diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index 0ea6b277e..77798514d 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -49,14 +49,16 @@ def test_pnm(tmp_path): with Image.open(f) as reloaded: assert_image_equal(im, reloaded) + def test_not_ppm(tmp_path): path = str(tmp_path / "temp.djvurle") with open(path, "wb") as f: - f.write(b"PyXX") + f.write(b"PyInvalid") with pytest.raises(UnidentifiedImageError): Image.open(path) + def test_header_with_comments(tmp_path): path = str(tmp_path / "temp.ppm") with open(path, "wb") as f: @@ -74,6 +76,7 @@ def test_nondecimal_header(tmp_path): with pytest.raises(ValueError): Image.open(path) + def test_token_too_long(tmp_path): path = str(tmp_path / "temp.djvurle") with open(path, "wb") as f: @@ -82,6 +85,16 @@ def test_token_too_long(tmp_path): with pytest.raises(ValueError): Image.open(path) + +def test_too_many_colors(tmp_path): + path = str(tmp_path / "temp.djvurle") + with open(path, "wb") as f: + f.write(b"P6\n1 1\n1000\n") + + with pytest.raises(ValueError): + Image.open(path) + + def test_truncated_file(tmp_path): path = str(tmp_path / "temp.pgm") with open(path, "w") as f: