Skip to content

Commit 0da83a1

Browse files
authored
Merge pull request #8053 from radarhere/helper_modes
2 parents 60c94e6 + db4714c commit 0da83a1

File tree

3 files changed

+11
-38
lines changed

3 files changed

+11
-38
lines changed

Tests/helper.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,6 @@
2929
uploader = "github_actions"
3030

3131

32-
modes = (
33-
"1",
34-
"L",
35-
"LA",
36-
"La",
37-
"P",
38-
"PA",
39-
"F",
40-
"I",
41-
"I;16",
42-
"I;16L",
43-
"I;16B",
44-
"I;16N",
45-
"RGB",
46-
"RGBA",
47-
"RGBa",
48-
"RGBX",
49-
"BGR;15",
50-
"BGR;16",
51-
"BGR;24",
52-
"CMYK",
53-
"YCbCr",
54-
"HSV",
55-
"LAB",
56-
)
57-
58-
5932
def upload(a: Image.Image, b: Image.Image) -> str | None:
6033
if uploader == "show":
6134
# local img.show for errors.

Tests/test_image.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
is_big_endian,
3232
is_win32,
3333
mark_if_feature_version,
34-
modes,
3534
skip_unless_feature,
3635
)
3736

@@ -46,7 +45,7 @@ def helper_image_new(mode: str, size: tuple[int, int]) -> Image.Image:
4645

4746

4847
class TestImage:
49-
@pytest.mark.parametrize("mode", modes)
48+
@pytest.mark.parametrize("mode", Image.MODES + ["BGR;15", "BGR;16", "BGR;24"])
5049
def test_image_modes_success(self, mode: str) -> None:
5150
helper_image_new(mode, (1, 1))
5251

@@ -1027,7 +1026,7 @@ def test_close_graceful(self, caplog: pytest.LogCaptureFixture) -> None:
10271026

10281027

10291028
class TestImageBytes:
1030-
@pytest.mark.parametrize("mode", modes)
1029+
@pytest.mark.parametrize("mode", Image.MODES + ["BGR;15", "BGR;16", "BGR;24"])
10311030
def test_roundtrip_bytes_constructor(self, mode: str) -> None:
10321031
im = hopper(mode)
10331032
source_bytes = im.tobytes()
@@ -1039,7 +1038,7 @@ def test_roundtrip_bytes_constructor(self, mode: str) -> None:
10391038
reloaded = Image.frombytes(mode, im.size, source_bytes)
10401039
assert reloaded.tobytes() == source_bytes
10411040

1042-
@pytest.mark.parametrize("mode", modes)
1041+
@pytest.mark.parametrize("mode", Image.MODES + ["BGR;15", "BGR;16", "BGR;24"])
10431042
def test_roundtrip_bytes_method(self, mode: str) -> None:
10441043
im = hopper(mode)
10451044
source_bytes = im.tobytes()
@@ -1048,7 +1047,7 @@ def test_roundtrip_bytes_method(self, mode: str) -> None:
10481047
reloaded.frombytes(source_bytes)
10491048
assert reloaded.tobytes() == source_bytes
10501049

1051-
@pytest.mark.parametrize("mode", modes)
1050+
@pytest.mark.parametrize("mode", Image.MODES + ["BGR;15", "BGR;16", "BGR;24"])
10521051
def test_getdata_putdata(self, mode: str) -> None:
10531052
if is_big_endian() and mode == "BGR;15":
10541053
pytest.xfail("Known failure of BGR;15 on big-endian")

Tests/test_image_access.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from PIL import Image
1212

13-
from .helper import assert_image_equal, hopper, is_win32, modes
13+
from .helper import assert_image_equal, hopper, is_win32
1414

1515
# CFFI imports pycparser which doesn't support PYTHONOPTIMIZE=2
1616
# https://github.com/eliben/pycparser/pull/198#issuecomment-317001670
@@ -205,12 +205,13 @@ def check(self, mode: str, expected_color_int: int | None = None) -> None:
205205
with pytest.raises(error):
206206
im.getpixel((-1, -1))
207207

208-
@pytest.mark.parametrize("mode", modes)
208+
@pytest.mark.parametrize("mode", Image.MODES)
209209
def test_basic(self, mode: str) -> None:
210-
if mode.startswith("BGR;"):
211-
with pytest.warns(DeprecationWarning):
212-
self.check(mode)
213-
else:
210+
self.check(mode)
211+
212+
@pytest.mark.parametrize("mode", ("BGR;15", "BGR;16", "BGR;24"))
213+
def test_deprecated(self, mode: str) -> None:
214+
with pytest.warns(DeprecationWarning):
214215
self.check(mode)
215216

216217
def test_list(self) -> None:

0 commit comments

Comments
 (0)