mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Add tests for token size and wrong magic number
This commit is contained in:
parent
5d0ad5e2e9
commit
002e0bd697
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user