Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not compare properties to themselves #5907

Merged
merged 1 commit into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tests/test_image_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def convert(im, mode):
def test_default():

im = hopper("P")
assert_image(im, "P", im.size)
assert im.mode == "P"
converted_im = im.convert()
assert_image(converted_im, "RGB", im.size)
converted_im = im.convert()
Expand Down
14 changes: 7 additions & 7 deletions Tests/test_image_quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

from PIL import Image

from .helper import assert_image, assert_image_similar, hopper, is_ppc64le
from .helper import assert_image_similar, hopper, is_ppc64le


def test_sanity():
image = hopper()
converted = image.quantize()
assert_image(converted, "P", converted.size)
assert converted.mode == "P"
assert_image_similar(converted.convert("RGB"), image, 10)

image = hopper()
converted = image.quantize(palette=hopper("P"))
assert_image(converted, "P", converted.size)
assert converted.mode == "P"
assert_image_similar(converted.convert("RGB"), image, 60)


Expand All @@ -27,15 +27,15 @@ def test_libimagequant_quantize():
pytest.skip("libimagequant support not available")
else:
raise
assert_image(converted, "P", converted.size)
assert converted.mode == "P"
assert_image_similar(converted.convert("RGB"), image, 15)
assert len(converted.getcolors()) == 100


def test_octree_quantize():
image = hopper()
converted = image.quantize(100, Image.FASTOCTREE)
assert_image(converted, "P", converted.size)
assert converted.mode == "P"
assert_image_similar(converted.convert("RGB"), image, 20)
assert len(converted.getcolors()) == 100

Expand All @@ -52,7 +52,7 @@ def test_quantize():
with Image.open("Tests/images/caption_6_33_22.png") as image:
image = image.convert("RGB")
converted = image.quantize()
assert_image(converted, "P", converted.size)
assert converted.mode == "P"
assert_image_similar(converted.convert("RGB"), image, 1)


Expand All @@ -62,7 +62,7 @@ def test_quantize_no_dither():
palette = palette.convert("P")

converted = image.quantize(dither=0, palette=palette)
assert_image(converted, "P", converted.size)
assert converted.mode == "P"
assert converted.palette.palette == palette.palette.palette


Expand Down
22 changes: 8 additions & 14 deletions Tests/test_imagegrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,28 @@

from PIL import Image, ImageGrab

from .helper import assert_image, assert_image_equal_tofile, skip_unless_feature
from .helper import assert_image_equal_tofile, skip_unless_feature


class TestImageGrab:
@pytest.mark.skipif(
sys.platform not in ("win32", "darwin"), reason="requires Windows or macOS"
)
def test_grab(self):
for im in [
ImageGrab.grab(),
ImageGrab.grab(include_layered_windows=True),
ImageGrab.grab(all_screens=True),
]:
assert_image(im, im.mode, im.size)
ImageGrab.grab()
ImageGrab.grab(include_layered_windows=True)
ImageGrab.grab(all_screens=True)

im = ImageGrab.grab(bbox=(10, 20, 50, 80))
assert_image(im, im.mode, (40, 60))
assert im.size == (40, 60)

@skip_unless_feature("xcb")
def test_grab_x11(self):
try:
if sys.platform not in ("win32", "darwin"):
im = ImageGrab.grab()
assert_image(im, im.mode, im.size)
ImageGrab.grab()

im2 = ImageGrab.grab(xdisplay="")
assert_image(im2, im2.mode, im2.size)
ImageGrab.grab(xdisplay="")
except OSError as e:
pytest.skip(str(e))

Expand Down Expand Up @@ -71,8 +66,7 @@ def test_grabclipboard(self):
assert str(e.value) == "ImageGrab.grabclipboard() is macOS and Windows only"
return

im = ImageGrab.grabclipboard()
assert_image(im, im.mode, im.size)
ImageGrab.grabclipboard()

@pytest.mark.skipif(sys.platform != "win32", reason="Windows only")
def test_grabclipboard_file(self):
Expand Down