Removed helper.py modes

This commit is contained in:
Andrew Murray 2024-05-12 21:20:46 +10:00
parent 0c8be38878
commit db4714c280
3 changed files with 11 additions and 38 deletions

View File

@ -29,33 +29,6 @@ elif "GITHUB_ACTIONS" in os.environ:
uploader = "github_actions" uploader = "github_actions"
modes = (
"1",
"L",
"LA",
"La",
"P",
"PA",
"F",
"I",
"I;16",
"I;16L",
"I;16B",
"I;16N",
"RGB",
"RGBA",
"RGBa",
"RGBX",
"BGR;15",
"BGR;16",
"BGR;24",
"CMYK",
"YCbCr",
"HSV",
"LAB",
)
def upload(a: Image.Image, b: Image.Image) -> str | None: def upload(a: Image.Image, b: Image.Image) -> str | None:
if uploader == "show": if uploader == "show":
# local img.show for errors. # local img.show for errors.

View File

@ -31,7 +31,6 @@ from .helper import (
is_big_endian, is_big_endian,
is_win32, is_win32,
mark_if_feature_version, mark_if_feature_version,
modes,
skip_unless_feature, skip_unless_feature,
) )
@ -46,7 +45,7 @@ def helper_image_new(mode: str, size: tuple[int, int]) -> Image.Image:
class TestImage: class TestImage:
@pytest.mark.parametrize("mode", modes) @pytest.mark.parametrize("mode", Image.MODES + ["BGR;15", "BGR;16", "BGR;24"])
def test_image_modes_success(self, mode: str) -> None: def test_image_modes_success(self, mode: str) -> None:
helper_image_new(mode, (1, 1)) helper_image_new(mode, (1, 1))
@ -1027,7 +1026,7 @@ class TestImage:
class TestImageBytes: class TestImageBytes:
@pytest.mark.parametrize("mode", modes) @pytest.mark.parametrize("mode", Image.MODES + ["BGR;15", "BGR;16", "BGR;24"])
def test_roundtrip_bytes_constructor(self, mode: str) -> None: def test_roundtrip_bytes_constructor(self, mode: str) -> None:
im = hopper(mode) im = hopper(mode)
source_bytes = im.tobytes() source_bytes = im.tobytes()
@ -1039,7 +1038,7 @@ class TestImageBytes:
reloaded = Image.frombytes(mode, im.size, source_bytes) reloaded = Image.frombytes(mode, im.size, source_bytes)
assert reloaded.tobytes() == source_bytes assert reloaded.tobytes() == source_bytes
@pytest.mark.parametrize("mode", modes) @pytest.mark.parametrize("mode", Image.MODES + ["BGR;15", "BGR;16", "BGR;24"])
def test_roundtrip_bytes_method(self, mode: str) -> None: def test_roundtrip_bytes_method(self, mode: str) -> None:
im = hopper(mode) im = hopper(mode)
source_bytes = im.tobytes() source_bytes = im.tobytes()
@ -1048,7 +1047,7 @@ class TestImageBytes:
reloaded.frombytes(source_bytes) reloaded.frombytes(source_bytes)
assert reloaded.tobytes() == source_bytes assert reloaded.tobytes() == source_bytes
@pytest.mark.parametrize("mode", modes) @pytest.mark.parametrize("mode", Image.MODES + ["BGR;15", "BGR;16", "BGR;24"])
def test_getdata_putdata(self, mode: str) -> None: def test_getdata_putdata(self, mode: str) -> None:
if is_big_endian() and mode == "BGR;15": if is_big_endian() and mode == "BGR;15":
pytest.xfail("Known failure of BGR;15 on big-endian") pytest.xfail("Known failure of BGR;15 on big-endian")

View File

@ -10,7 +10,7 @@ import pytest
from PIL import Image from PIL import Image
from .helper import assert_image_equal, hopper, is_win32, modes from .helper import assert_image_equal, hopper, is_win32
# CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2 # CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2
# https://github.com/eliben/pycparser/pull/198#issuecomment-317001670 # https://github.com/eliben/pycparser/pull/198#issuecomment-317001670
@ -205,12 +205,13 @@ class TestImageGetPixel(AccessTest):
with pytest.raises(error): with pytest.raises(error):
im.getpixel((-1, -1)) im.getpixel((-1, -1))
@pytest.mark.parametrize("mode", modes) @pytest.mark.parametrize("mode", Image.MODES)
def test_basic(self, mode: str) -> None: def test_basic(self, mode: str) -> None:
if mode.startswith("BGR;"): self.check(mode)
with pytest.warns(DeprecationWarning):
self.check(mode) @pytest.mark.parametrize("mode", ("BGR;15", "BGR;16", "BGR;24"))
else: def test_deprecated(self, mode: str) -> None:
with pytest.warns(DeprecationWarning):
self.check(mode) self.check(mode)
def test_list(self) -> None: def test_list(self) -> None: