mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Merge pull request #775 from radarhere/master
Added class checking to Image __eq__ function
This commit is contained in:
commit
737c7440d7
|
@ -573,6 +573,8 @@ class Image:
|
||||||
return file
|
return file
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
if self.__class__.__name__ != other.__class__.__name__:
|
||||||
|
return False
|
||||||
a = (self.mode == other.mode)
|
a = (self.mode == other.mode)
|
||||||
b = (self.size == other.size)
|
b = (self.size == other.size)
|
||||||
c = (self.getpalette() == other.getpalette())
|
c = (self.getpalette() == other.getpalette())
|
||||||
|
|
|
@ -44,6 +44,17 @@ class TestImage(PillowTestCase):
|
||||||
file = self.tempfile("temp.ppm")
|
file = self.tempfile("temp.ppm")
|
||||||
im._dump(file)
|
im._dump(file)
|
||||||
|
|
||||||
|
def test_comparison_with_other_type(self):
|
||||||
|
# Arrange
|
||||||
|
item = Image.new('RGB', (25, 25), '#000')
|
||||||
|
num = 12
|
||||||
|
|
||||||
|
# Act/Assert
|
||||||
|
# Shouldn't cause AttributeError (#774)
|
||||||
|
self.assertFalse(item is None)
|
||||||
|
self.assertFalse(item == None)
|
||||||
|
self.assertFalse(item == num)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user