mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #4888 from radarhere/bugfix/ifdrational-equality
Fix IFDRational __eq__ bug
This commit is contained in:
commit
9b86da9c26
|
@ -242,6 +242,16 @@ class TestFileJpeg:
|
||||||
# Assert
|
# Assert
|
||||||
assert exif[gps_index] == expected_exif_gps
|
assert exif[gps_index] == expected_exif_gps
|
||||||
|
|
||||||
|
def test_exif_equality(self):
|
||||||
|
# In 7.2.0, Exif rationals were changed to be read as
|
||||||
|
# TiffImagePlugin.IFDRational. This class had a bug in __eq__,
|
||||||
|
# breaking the self-equality of Exif data
|
||||||
|
exifs = []
|
||||||
|
for i in range(2):
|
||||||
|
with Image.open("Tests/images/exif-200dpcm.jpg") as im:
|
||||||
|
exifs.append(im._getexif())
|
||||||
|
assert exifs[0] == exifs[1]
|
||||||
|
|
||||||
def test_exif_rollback(self):
|
def test_exif_rollback(self):
|
||||||
# rolling back exif support in 3.1 to pre-3.0 formatting.
|
# rolling back exif support in 3.1 to pre-3.0 formatting.
|
||||||
# expected from 2.9, with b/u qualifiers switched for 3.2 compatibility
|
# expected from 2.9, with b/u qualifiers switched for 3.2 compatibility
|
||||||
|
|
|
@ -29,6 +29,12 @@ def test_sanity():
|
||||||
_test_equal(1, 2, IFDRational(1, 2))
|
_test_equal(1, 2, IFDRational(1, 2))
|
||||||
|
|
||||||
|
|
||||||
|
def test_ranges():
|
||||||
|
for num in range(1, 10):
|
||||||
|
for denom in range(1, 10):
|
||||||
|
assert IFDRational(num, denom) == IFDRational(num, denom)
|
||||||
|
|
||||||
|
|
||||||
def test_nonetype():
|
def test_nonetype():
|
||||||
# Fails if the _delegate function doesn't return a valid function
|
# Fails if the _delegate function doesn't return a valid function
|
||||||
|
|
||||||
|
|
|
@ -353,6 +353,8 @@ class IFDRational(Rational):
|
||||||
return self._val.__hash__()
|
return self._val.__hash__()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
if isinstance(other, IFDRational):
|
||||||
|
other = other._val
|
||||||
return self._val == other
|
return self._val == other
|
||||||
|
|
||||||
def _delegate(op):
|
def _delegate(op):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user