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

Conversation

radarhere
Copy link
Member

The assert_image helper method is useful to assert an image's mode and size.

Pillow/Tests/helper.py

Lines 77 to 86 in 9d0703a

def assert_image(im, mode, size, msg=None):
if mode is not None:
assert im.mode == mode, (
msg or f"got mode {repr(im.mode)}, expected {repr(mode)}"
)
if size is not None:
assert im.size == size, (
msg or f"got size {repr(im.size)}, expected {repr(size)}"
)

However, I think that

assert_image(im, "P", im.size)

could be more clearly expressed as

assert im.mode == "P"

Similarly,

assert_image(im, im.mode, (40, 60))

should be changed to

assert im.size == (40, 60)

And

assert_image(im, im.mode, im.size)

seems redundant.

@hugovk hugovk merged commit 11c536b into python-pillow:main Dec 26, 2021
@radarhere radarhere deleted the assert_image branch December 26, 2021 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants