Skip to content

Commit a7524a3

Browse files
authored
Merge pull request #8727 from radarhere/getpixel
2 parents 2810d7c + ce1996d commit a7524a3

File tree

6 files changed

+12
-25
lines changed

6 files changed

+12
-25
lines changed

Tests/test_file_gif.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ def test_invalid_file() -> None:
8686
def test_l_mode_transparency() -> None:
8787
with Image.open("Tests/images/no_palette_with_transparency.gif") as im:
8888
assert im.mode == "L"
89-
assert im.load()[0, 0] == 128
89+
assert im.getpixel((0, 0)) == 128
9090
assert im.info["transparency"] == 255
9191

9292
im.seek(1)
9393
assert im.mode == "L"
94-
assert im.load()[0, 0] == 128
94+
assert im.getpixel((0, 0)) == 128
9595

9696

9797
def test_l_mode_after_rgb() -> None:
@@ -311,18 +311,18 @@ def test_loading_multiple_palettes(path: str, mode: str) -> None:
311311
with Image.open(path) as im:
312312
assert im.mode == "P"
313313
first_frame_colors = im.palette.colors.keys()
314-
original_color = im.convert("RGB").load()[0, 0]
314+
original_color = im.convert("RGB").getpixel((0, 0))
315315

316316
im.seek(1)
317317
assert im.mode == mode
318318
if mode == "RGBA":
319319
im = im.convert("RGB")
320320

321321
# Check a color only from the old palette
322-
assert im.load()[0, 0] == original_color
322+
assert im.getpixel((0, 0)) == original_color
323323

324324
# Check a color from the new palette
325-
assert im.load()[24, 24] not in first_frame_colors
325+
assert im.getpixel((24, 24)) not in first_frame_colors
326326

327327

328328
def test_headers_saving_for_animated_gifs(tmp_path: Path) -> None:
@@ -488,8 +488,7 @@ def test_eoferror() -> None:
488488

489489
def test_first_frame_transparency() -> None:
490490
with Image.open("Tests/images/first_frame_transparency.gif") as im:
491-
px = im.load()
492-
assert px[0, 0] == im.info["transparency"]
491+
assert im.getpixel((0, 0)) == im.info["transparency"]
493492

494493

495494
def test_dispose_none() -> None:

Tests/test_image.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,7 @@ def test_storage_neg(self) -> None:
578578
def test_one_item_tuple(self) -> None:
579579
for mode in ("I", "F", "L"):
580580
im = Image.new(mode, (100, 100), (5,))
581-
px = im.load()
582-
assert px is not None
583-
assert px[0, 0] == 5
581+
assert im.getpixel((0, 0)) == 5
584582

585583
def test_linear_gradient_wrong_mode(self) -> None:
586584
# Arrange

Tests/test_image_convert.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ def test_l_macro_rounding(convert_mode: str) -> None:
222222
im.palette.getcolor((0, 1, 2))
223223

224224
converted_im = im.convert(convert_mode)
225-
px = converted_im.load()
226-
assert px is not None
227-
converted_color = px[0, 0]
225+
converted_color = converted_im.getpixel((0, 0))
228226
if convert_mode == "LA":
229227
assert isinstance(converted_color, tuple)
230228
converted_color = converted_color[0]

Tests/test_image_quantize.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@ def test_palette(method: Image.Quantize, color: tuple[int, ...]) -> None:
148148
im = Image.new("RGBA" if len(color) == 4 else "RGB", (1, 1), color)
149149

150150
converted = im.quantize(method=method)
151-
converted_px = converted.load()
152-
assert converted_px is not None
153151
assert converted.palette is not None
154-
assert converted_px[0, 0] == converted.palette.colors[color]
152+
assert converted.getpixel((0, 0)) == converted.palette.colors[color]
155153

156154

157155
def test_small_palette() -> None:

Tests/test_imageops.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,10 @@ def test_pad() -> None:
165165
def test_pad_round() -> None:
166166
im = Image.new("1", (1, 1), 1)
167167
new_im = ImageOps.pad(im, (4, 1))
168-
px = new_im.load()
169-
assert px is not None
170-
assert px[2, 0] == 1
168+
assert new_im.getpixel((2, 0)) == 1
171169

172170
new_im = ImageOps.pad(im, (1, 4))
173-
px = new_im.load()
174-
assert px is not None
175-
assert px[0, 2] == 1
171+
assert new_im.getpixel((0, 2)) == 1
176172

177173

178174
@pytest.mark.parametrize("mode", ("P", "PA"))

Tests/test_numpy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ def test_save_tiff_uint16() -> None:
141141
a.shape = TEST_IMAGE_SIZE
142142
img = Image.fromarray(a)
143143

144-
img_px = img.load()
145-
assert img_px is not None
146-
assert img_px[0, 0] == pixel_value
144+
assert img.getpixel((0, 0)) == pixel_value
147145

148146

149147
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)