Use monkeypatch

This commit is contained in:
Andrew Murray 2025-02-12 18:36:14 +11:00
parent 3c2310e090
commit 8020d423bc

View File

@ -1345,7 +1345,7 @@ def test_save_I(tmp_path: Path) -> None:
assert_image_equal(reloaded.convert("L"), im.convert("L")) assert_image_equal(reloaded.convert("L"), im.convert("L"))
def test_getdata() -> None: def test_getdata(monkeypatch: pytest.MonkeyPatch) -> None:
# Test getheader/getdata against legacy values. # Test getheader/getdata against legacy values.
# Create a 'P' image with holes in the palette. # Create a 'P' image with holes in the palette.
im = Image._wedge().resize((16, 16), Image.Resampling.NEAREST) im = Image._wedge().resize((16, 16), Image.Resampling.NEAREST)
@ -1354,8 +1354,8 @@ def test_getdata() -> None:
passed_palette = bytes(255 - i // 3 for i in range(768)) passed_palette = bytes(255 - i // 3 for i in range(768))
GifImagePlugin._FORCE_OPTIMIZE = True monkeypatch.setattr(GifImagePlugin, "_FORCE_OPTIMIZE", True)
try:
h = GifImagePlugin.getheader(im, passed_palette) h = GifImagePlugin.getheader(im, passed_palette)
d = GifImagePlugin.getdata(im) d = GifImagePlugin.getdata(im)
@ -1369,8 +1369,6 @@ def test_getdata() -> None:
assert h == h_target assert h == h_target
assert d == d_target assert d == d_target
finally:
GifImagePlugin._FORCE_OPTIMIZE = False
def test_lzw_bits() -> None: def test_lzw_bits() -> None: