mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 10:16:17 +03:00
Merge pull request #8679 from radarhere/test
This commit is contained in:
commit
3111e37bf4
|
@ -140,18 +140,11 @@ def assert_image_similar_tofile(
|
||||||
filename: str,
|
filename: str,
|
||||||
epsilon: float,
|
epsilon: float,
|
||||||
msg: str | None = None,
|
msg: str | None = None,
|
||||||
mode: str | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
with Image.open(filename) as img:
|
with Image.open(filename) as img:
|
||||||
if mode:
|
|
||||||
img = img.convert(mode)
|
|
||||||
assert_image_similar(a, img, epsilon, msg)
|
assert_image_similar(a, img, epsilon, msg)
|
||||||
|
|
||||||
|
|
||||||
def assert_all_same(items: Sequence[Any], msg: str | None = None) -> None:
|
|
||||||
assert items.count(items[0]) == len(items), msg
|
|
||||||
|
|
||||||
|
|
||||||
def assert_not_all_same(items: Sequence[Any], msg: str | None = None) -> None:
|
def assert_not_all_same(items: Sequence[Any], msg: str | None = None) -> None:
|
||||||
assert items.count(items[0]) != len(items), msg
|
assert items.count(items[0]) != len(items), msg
|
||||||
|
|
||||||
|
|
|
@ -307,13 +307,8 @@ def test_apng_syntax_errors() -> None:
|
||||||
im.load()
|
im.load()
|
||||||
|
|
||||||
# we can handle this case gracefully
|
# we can handle this case gracefully
|
||||||
exception = None
|
|
||||||
with Image.open("Tests/images/apng/syntax_num_frames_low.png") as im:
|
with Image.open("Tests/images/apng/syntax_num_frames_low.png") as im:
|
||||||
try:
|
|
||||||
im.seek(im.n_frames - 1)
|
im.seek(im.n_frames - 1)
|
||||||
except Exception as e:
|
|
||||||
exception = e
|
|
||||||
assert exception is None
|
|
||||||
|
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
with Image.open("Tests/images/apng/syntax_num_frames_high.png") as im:
|
with Image.open("Tests/images/apng/syntax_num_frames_high.png") as im:
|
||||||
|
@ -405,13 +400,8 @@ def test_apng_save_split_fdat(tmp_path: Path) -> None:
|
||||||
append_images=frames,
|
append_images=frames,
|
||||||
)
|
)
|
||||||
with Image.open(test_file) as im:
|
with Image.open(test_file) as im:
|
||||||
exception = None
|
|
||||||
try:
|
|
||||||
im.seek(im.n_frames - 1)
|
im.seek(im.n_frames - 1)
|
||||||
im.load()
|
im.load()
|
||||||
except Exception as e:
|
|
||||||
exception = e
|
|
||||||
assert exception is None
|
|
||||||
|
|
||||||
|
|
||||||
def test_apng_save_duration_loop(tmp_path: Path) -> None:
|
def test_apng_save_duration_loop(tmp_path: Path) -> None:
|
||||||
|
|
|
@ -58,10 +58,7 @@ def test_getiptcinfo_fotostation() -> None:
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert iptc is not None
|
assert iptc is not None
|
||||||
for tag in iptc.keys():
|
assert 240 in (tag[0] for tag in iptc.keys()), "FotoStation tag not found"
|
||||||
if tag[0] == 240:
|
|
||||||
return
|
|
||||||
pytest.fail("FotoStation tag not found")
|
|
||||||
|
|
||||||
|
|
||||||
def test_getiptcinfo_zero_padding() -> None:
|
def test_getiptcinfo_zero_padding() -> None:
|
||||||
|
|
|
@ -492,8 +492,7 @@ def test_plt_marker(card: ImageFile.ImageFile) -> None:
|
||||||
out.seek(0)
|
out.seek(0)
|
||||||
while True:
|
while True:
|
||||||
marker = out.read(2)
|
marker = out.read(2)
|
||||||
if not marker:
|
assert marker, "End of stream without PLT"
|
||||||
pytest.fail("End of stream without PLT")
|
|
||||||
|
|
||||||
jp2_boxid = _binary.i16be(marker)
|
jp2_boxid = _binary.i16be(marker)
|
||||||
if jp2_boxid == 0xFF4F:
|
if jp2_boxid == 0xFF4F:
|
||||||
|
|
|
@ -36,11 +36,7 @@ class LibTiffTestCase:
|
||||||
im.load()
|
im.load()
|
||||||
im.getdata()
|
im.getdata()
|
||||||
|
|
||||||
try:
|
|
||||||
assert im._compression == "group4"
|
assert im._compression == "group4"
|
||||||
except AttributeError:
|
|
||||||
print("No _compression")
|
|
||||||
print(dir(im))
|
|
||||||
|
|
||||||
# can we write it back out, in a different form.
|
# can we write it back out, in a different form.
|
||||||
out = str(tmp_path / "temp.png")
|
out = str(tmp_path / "temp.png")
|
||||||
|
|
|
@ -189,8 +189,6 @@ class TestImage:
|
||||||
if ext == ".jp2" and not features.check_codec("jpg_2000"):
|
if ext == ".jp2" and not features.check_codec("jpg_2000"):
|
||||||
pytest.skip("jpg_2000 not available")
|
pytest.skip("jpg_2000 not available")
|
||||||
temp_file = str(tmp_path / ("temp." + ext))
|
temp_file = str(tmp_path / ("temp." + ext))
|
||||||
if os.path.exists(temp_file):
|
|
||||||
os.remove(temp_file)
|
|
||||||
im.save(Path(temp_file))
|
im.save(Path(temp_file))
|
||||||
|
|
||||||
def test_fp_name(self, tmp_path: Path) -> None:
|
def test_fp_name(self, tmp_path: Path) -> None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user