mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
[Test] function name should be snake_case
This commit is contained in:
parent
fca64bc0d3
commit
a715bf2d6f
|
@ -25,7 +25,7 @@ def box_blur(image, radius=1, n=1):
|
|||
return image._new(image.im.box_blur(radius, n))
|
||||
|
||||
|
||||
def assertImage(im, data, delta=0):
|
||||
def assert_image(im, data, delta=0):
|
||||
it = iter(im.getdata())
|
||||
for data_row in data:
|
||||
im_row = [next(it) for _ in range(im.size[0])]
|
||||
|
@ -35,12 +35,12 @@ def assertImage(im, data, delta=0):
|
|||
next(it)
|
||||
|
||||
|
||||
def assertBlur(im, radius, data, passes=1, delta=0):
|
||||
def assert_blur(im, radius, data, passes=1, delta=0):
|
||||
# check grayscale image
|
||||
assertImage(box_blur(im, radius, passes), data, delta)
|
||||
assert_image(box_blur(im, radius, passes), data, delta)
|
||||
rgba = Image.merge("RGBA", (im, im, im, im))
|
||||
for band in box_blur(rgba, radius, passes).split():
|
||||
assertImage(band, data, delta)
|
||||
assert_image(band, data, delta)
|
||||
|
||||
|
||||
def test_color_modes():
|
||||
|
@ -64,7 +64,7 @@ def test_color_modes():
|
|||
|
||||
|
||||
def test_radius_0():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
0,
|
||||
[
|
||||
|
@ -80,7 +80,7 @@ def test_radius_0():
|
|||
|
||||
|
||||
def test_radius_0_02():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
0.02,
|
||||
[
|
||||
|
@ -97,7 +97,7 @@ def test_radius_0_02():
|
|||
|
||||
|
||||
def test_radius_0_05():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
0.05,
|
||||
[
|
||||
|
@ -114,7 +114,7 @@ def test_radius_0_05():
|
|||
|
||||
|
||||
def test_radius_0_1():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
0.1,
|
||||
[
|
||||
|
@ -131,7 +131,7 @@ def test_radius_0_1():
|
|||
|
||||
|
||||
def test_radius_0_5():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
0.5,
|
||||
[
|
||||
|
@ -148,7 +148,7 @@ def test_radius_0_5():
|
|||
|
||||
|
||||
def test_radius_1():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
1,
|
||||
[
|
||||
|
@ -165,7 +165,7 @@ def test_radius_1():
|
|||
|
||||
|
||||
def test_radius_1_5():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
1.5,
|
||||
[
|
||||
|
@ -182,7 +182,7 @@ def test_radius_1_5():
|
|||
|
||||
|
||||
def test_radius_bigger_then_half():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
3,
|
||||
[
|
||||
|
@ -199,7 +199,7 @@ def test_radius_bigger_then_half():
|
|||
|
||||
|
||||
def test_radius_bigger_then_width():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
10,
|
||||
[
|
||||
|
@ -214,7 +214,7 @@ def test_radius_bigger_then_width():
|
|||
|
||||
|
||||
def test_extreme_large_radius():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
600,
|
||||
[
|
||||
|
@ -229,7 +229,7 @@ def test_extreme_large_radius():
|
|||
|
||||
|
||||
def test_two_passes():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
1,
|
||||
[
|
||||
|
@ -247,7 +247,7 @@ def test_two_passes():
|
|||
|
||||
|
||||
def test_three_passes():
|
||||
assertBlur(
|
||||
assert_blur(
|
||||
sample,
|
||||
1,
|
||||
[
|
||||
|
|
|
@ -78,7 +78,7 @@ class TestDecompressionCrop:
|
|||
def teardown_class(self):
|
||||
Image.MAX_IMAGE_PIXELS = ORIGINAL_LIMIT
|
||||
|
||||
def testEnlargeCrop(self):
|
||||
def test_enlarge_crop(self):
|
||||
# Crops can extend the extents, therefore we should have the
|
||||
# same decompression bomb warnings on them.
|
||||
with hopper() as src:
|
||||
|
|
|
@ -799,31 +799,31 @@ def test_zero_comment_subblocks():
|
|||
def test_version(tmp_path):
|
||||
out = str(tmp_path / "temp.gif")
|
||||
|
||||
def assertVersionAfterSave(im, version):
|
||||
def assert_version_after_save(im, version):
|
||||
im.save(out)
|
||||
with Image.open(out) as reread:
|
||||
assert reread.info["version"] == version
|
||||
|
||||
# Test that GIF87a is used by default
|
||||
im = Image.new("L", (100, 100), "#000")
|
||||
assertVersionAfterSave(im, b"GIF87a")
|
||||
assert_version_after_save(im, b"GIF87a")
|
||||
|
||||
# Test setting the version to 89a
|
||||
im = Image.new("L", (100, 100), "#000")
|
||||
im.info["version"] = b"89a"
|
||||
assertVersionAfterSave(im, b"GIF89a")
|
||||
assert_version_after_save(im, b"GIF89a")
|
||||
|
||||
# Test that adding a GIF89a feature changes the version
|
||||
im.info["transparency"] = 1
|
||||
assertVersionAfterSave(im, b"GIF89a")
|
||||
assert_version_after_save(im, b"GIF89a")
|
||||
|
||||
# Test that a GIF87a image is also saved in that format
|
||||
with Image.open("Tests/images/test.colors.gif") as im:
|
||||
assertVersionAfterSave(im, b"GIF87a")
|
||||
assert_version_after_save(im, b"GIF87a")
|
||||
|
||||
# Test that a GIF89a image is also saved in that format
|
||||
im.info["version"] = b"GIF89a"
|
||||
assertVersionAfterSave(im, b"GIF87a")
|
||||
assert_version_after_save(im, b"GIF87a")
|
||||
|
||||
|
||||
def test_append_images(tmp_path):
|
||||
|
@ -838,10 +838,10 @@ def test_append_images(tmp_path):
|
|||
assert reread.n_frames == 3
|
||||
|
||||
# Tests appending using a generator
|
||||
def imGenerator(ims):
|
||||
def im_generator(ims):
|
||||
yield from ims
|
||||
|
||||
im.save(out, save_all=True, append_images=imGenerator(ims))
|
||||
im.save(out, save_all=True, append_images=im_generator(ims))
|
||||
|
||||
with Image.open(out) as reread:
|
||||
assert reread.n_frames == 3
|
||||
|
|
|
@ -131,10 +131,10 @@ def test_save_all(tmp_path):
|
|||
assert os.path.getsize(outfile) > 0
|
||||
|
||||
# Test appending using a generator
|
||||
def imGenerator(ims):
|
||||
def im_generator(ims):
|
||||
yield from ims
|
||||
|
||||
im.save(outfile, save_all=True, append_images=imGenerator(ims))
|
||||
im.save(outfile, save_all=True, append_images=im_generator(ims))
|
||||
|
||||
assert os.path.isfile(outfile)
|
||||
assert os.path.getsize(outfile) > 0
|
||||
|
|
|
@ -655,11 +655,11 @@ class TestFileTiff:
|
|||
assert reread.n_frames == 3
|
||||
|
||||
# Test appending using a generator
|
||||
def imGenerator(ims):
|
||||
def im_generator(ims):
|
||||
yield from ims
|
||||
|
||||
mp = BytesIO()
|
||||
im.save(mp, format="TIFF", save_all=True, append_images=imGenerator(ims))
|
||||
im.save(mp, format="TIFF", save_all=True, append_images=im_generator(ims))
|
||||
|
||||
mp.seek(0, os.SEEK_SET)
|
||||
with Image.open(mp) as reread:
|
||||
|
|
|
@ -356,7 +356,7 @@ def test_empty_values():
|
|||
assert 33432 in info
|
||||
|
||||
|
||||
def test_PhotoshopInfo(tmp_path):
|
||||
def test_photoshop_info(tmp_path):
|
||||
with Image.open("Tests/images/issue_2278.tif") as im:
|
||||
assert len(im.tag_v2[34377]) == 70
|
||||
assert isinstance(im.tag_v2[34377], bytes)
|
||||
|
|
|
@ -90,14 +90,14 @@ def test_write_animation_RGB(tmp_path):
|
|||
check(temp_file1)
|
||||
|
||||
# Tests appending using a generator
|
||||
def imGenerator(ims):
|
||||
def im_generator(ims):
|
||||
yield from ims
|
||||
|
||||
temp_file2 = str(tmp_path / "temp_generator.webp")
|
||||
frame1.copy().save(
|
||||
temp_file2,
|
||||
save_all=True,
|
||||
append_images=imGenerator([frame2]),
|
||||
append_images=im_generator([frame2]),
|
||||
lossless=True,
|
||||
)
|
||||
check(temp_file2)
|
||||
|
|
Loading…
Reference in New Issue
Block a user