mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 10:16:17 +03:00
Apply suggestions from code review
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
2fd3cb55d2
commit
09a7255ced
|
@ -52,11 +52,11 @@ def test_args_factor(size, expected):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"size,error", ((0, ValueError), (2.0, TypeError), ((0, 10), ValueError))
|
||||
"size, expected_error", ((0, ValueError), (2.0, TypeError), ((0, 10), ValueError))
|
||||
)
|
||||
def test_args_factor_error(size, error):
|
||||
def test_args_factor_error(size, expected_error):
|
||||
im = Image.new("L", (10, 10))
|
||||
with pytest.raises(error):
|
||||
with pytest.raises(expected_error):
|
||||
im.reduce(size)
|
||||
|
||||
|
||||
|
@ -73,7 +73,7 @@ def test_args_box(size, expected):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"size,error",
|
||||
"size, expected_error",
|
||||
(
|
||||
("stri", TypeError),
|
||||
((0, 0, 11, 10), ValueError),
|
||||
|
@ -84,9 +84,9 @@ def test_args_box(size, expected):
|
|||
((5, 0, 5, 10), ValueError),
|
||||
),
|
||||
)
|
||||
def test_args_box_error(size, error):
|
||||
def test_args_box_error(size, expected_error):
|
||||
im = Image.new("L", (10, 10))
|
||||
with pytest.raises(error):
|
||||
with pytest.raises(expected_error):
|
||||
im.reduce(2, size).size
|
||||
|
||||
|
||||
|
|
|
@ -76,14 +76,14 @@ class TestImageTransform:
|
|||
assert_image_equal(transformed, scaled)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"mode,pixel",
|
||||
"mode, expected_pixel",
|
||||
(
|
||||
("RGB", (255, 0, 0)),
|
||||
("RGBA", (255, 0, 0, 255)),
|
||||
("LA", (76, 0)),
|
||||
),
|
||||
)
|
||||
def test_fill(self, mode, pixel):
|
||||
def test_fill(self, mode, expected_pixel):
|
||||
im = hopper(mode)
|
||||
(w, h) = im.size
|
||||
transformed = im.transform(
|
||||
|
@ -93,7 +93,7 @@ class TestImageTransform:
|
|||
Image.Resampling.BILINEAR,
|
||||
fillcolor="red",
|
||||
)
|
||||
assert transformed.getpixel((w - 1, h - 1)) == pixel
|
||||
assert transformed.getpixel((w - 1, h - 1)) == expected_pixel
|
||||
|
||||
def test_mesh(self):
|
||||
# this should be a checkerboard of halfsized hoppers in ul, lr
|
||||
|
@ -281,7 +281,7 @@ class TestImageTransformAffine:
|
|||
assert_image_equal(transposed, transformed)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"scale,epsilonscale",
|
||||
"scale, epsilon_scale",
|
||||
(
|
||||
(1.1, 6.9),
|
||||
(1.5, 5.5),
|
||||
|
@ -298,7 +298,7 @@ class TestImageTransformAffine:
|
|||
(Image.Resampling.BICUBIC, 1),
|
||||
),
|
||||
)
|
||||
def test_resize(self, scale, epsilonscale, resample, epsilon):
|
||||
def test_resize(self, scale, epsilon_scale, resample, epsilon):
|
||||
im = self._test_image()
|
||||
|
||||
size_up = int(round(im.width * scale)), int(round(im.height * scale))
|
||||
|
@ -309,10 +309,10 @@ class TestImageTransformAffine:
|
|||
transformed = transformed.transform(
|
||||
im.size, self.transform, matrix_down, resample
|
||||
)
|
||||
assert_image_similar(transformed, im, epsilon * epsilonscale)
|
||||
assert_image_similar(transformed, im, epsilon * epsilon_scale)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"x,y,epsilonscale",
|
||||
"x, y, epsilon_scale",
|
||||
(
|
||||
(0.1, 0, 3.7),
|
||||
(0.6, 0, 9.1),
|
||||
|
@ -327,7 +327,7 @@ class TestImageTransformAffine:
|
|||
(Image.Resampling.BICUBIC, 1),
|
||||
),
|
||||
)
|
||||
def test_translate(self, x, y, epsilonscale, resample, epsilon):
|
||||
def test_translate(self, x, y, epsilon_scale, resample, epsilon):
|
||||
im = self._test_image()
|
||||
|
||||
size_up = int(round(im.width + x)), int(round(im.height + y))
|
||||
|
@ -338,7 +338,7 @@ class TestImageTransformAffine:
|
|||
transformed = transformed.transform(
|
||||
im.size, self.transform, matrix_down, resample
|
||||
)
|
||||
assert_image_similar(transformed, im, epsilon * epsilonscale)
|
||||
assert_image_similar(transformed, im, epsilon * epsilon_scale)
|
||||
|
||||
|
||||
class TestImageTransformPerspective(TestImageTransformAffine):
|
||||
|
|
Loading…
Reference in New Issue
Block a user