Apply suggestions from code review

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
Yay295 2022-08-29 11:35:06 -05:00 committed by GitHub
parent 2fd3cb55d2
commit 09a7255ced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 20 deletions

View File

@ -52,11 +52,11 @@ def test_args_factor(size, expected):
@pytest.mark.parametrize( @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)) im = Image.new("L", (10, 10))
with pytest.raises(error): with pytest.raises(expected_error):
im.reduce(size) im.reduce(size)
@ -73,7 +73,7 @@ def test_args_box(size, expected):
@pytest.mark.parametrize( @pytest.mark.parametrize(
"size,error", "size, expected_error",
( (
("stri", TypeError), ("stri", TypeError),
((0, 0, 11, 10), ValueError), ((0, 0, 11, 10), ValueError),
@ -84,9 +84,9 @@ def test_args_box(size, expected):
((5, 0, 5, 10), ValueError), ((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)) im = Image.new("L", (10, 10))
with pytest.raises(error): with pytest.raises(expected_error):
im.reduce(2, size).size im.reduce(2, size).size

View File

@ -76,14 +76,14 @@ class TestImageTransform:
assert_image_equal(transformed, scaled) assert_image_equal(transformed, scaled)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"mode,pixel", "mode, expected_pixel",
( (
("RGB", (255, 0, 0)), ("RGB", (255, 0, 0)),
("RGBA", (255, 0, 0, 255)), ("RGBA", (255, 0, 0, 255)),
("LA", (76, 0)), ("LA", (76, 0)),
), ),
) )
def test_fill(self, mode, pixel): def test_fill(self, mode, expected_pixel):
im = hopper(mode) im = hopper(mode)
(w, h) = im.size (w, h) = im.size
transformed = im.transform( transformed = im.transform(
@ -93,7 +93,7 @@ class TestImageTransform:
Image.Resampling.BILINEAR, Image.Resampling.BILINEAR,
fillcolor="red", fillcolor="red",
) )
assert transformed.getpixel((w - 1, h - 1)) == pixel assert transformed.getpixel((w - 1, h - 1)) == expected_pixel
def test_mesh(self): def test_mesh(self):
# this should be a checkerboard of halfsized hoppers in ul, lr # this should be a checkerboard of halfsized hoppers in ul, lr
@ -281,7 +281,7 @@ class TestImageTransformAffine:
assert_image_equal(transposed, transformed) assert_image_equal(transposed, transformed)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"scale,epsilonscale", "scale, epsilon_scale",
( (
(1.1, 6.9), (1.1, 6.9),
(1.5, 5.5), (1.5, 5.5),
@ -298,7 +298,7 @@ class TestImageTransformAffine:
(Image.Resampling.BICUBIC, 1), (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() im = self._test_image()
size_up = int(round(im.width * scale)), int(round(im.height * scale)) size_up = int(round(im.width * scale)), int(round(im.height * scale))
@ -309,10 +309,10 @@ class TestImageTransformAffine:
transformed = transformed.transform( transformed = transformed.transform(
im.size, self.transform, matrix_down, resample 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( @pytest.mark.parametrize(
"x,y,epsilonscale", "x, y, epsilon_scale",
( (
(0.1, 0, 3.7), (0.1, 0, 3.7),
(0.6, 0, 9.1), (0.6, 0, 9.1),
@ -327,7 +327,7 @@ class TestImageTransformAffine:
(Image.Resampling.BICUBIC, 1), (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() im = self._test_image()
size_up = int(round(im.width + x)), int(round(im.height + y)) size_up = int(round(im.width + x)), int(round(im.height + y))
@ -338,7 +338,7 @@ class TestImageTransformAffine:
transformed = transformed.transform( transformed = transformed.transform(
im.size, self.transform, matrix_down, resample 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): class TestImageTransformPerspective(TestImageTransformAffine):