diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py index 21a810e30..0ea6b277e 100644 --- a/Tests/test_file_ppm.py +++ b/Tests/test_file_ppm.py @@ -49,6 +49,13 @@ 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") + + with pytest.raises(UnidentifiedImageError): + Image.open(path) def test_header_with_comments(tmp_path): path = str(tmp_path / "temp.ppm") @@ -67,6 +74,13 @@ 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: + f.write(b"P6\n 0123456789") + + with pytest.raises(ValueError): + Image.open(path) def test_truncated_file(tmp_path): path = str(tmp_path / "temp.pgm")