Kaydet (Commit) 19e20a2a authored tarafından Adam Chainz's avatar Adam Chainz Kaydeden (comit) Tim Graham

Fixed crash comparing CheckMessage objects to non-CheckMessage objects.

üst 68b58032
......@@ -23,8 +23,11 @@ class CheckMessage(object):
self.id = id
def __eq__(self, other):
return all(getattr(self, attr) == getattr(other, attr)
for attr in ['level', 'msg', 'hint', 'obj', 'id'])
return (
isinstance(other, self.__class__) and
all(getattr(self, attr) == getattr(other, attr)
for attr in ['level', 'msg', 'hint', 'obj', 'id'])
)
def __ne__(self, other):
return not (self == other)
......
......@@ -124,6 +124,10 @@ class MessageTests(SimpleTestCase):
e2 = Error("Error2", obj=SimpleModel)
self.assertNotEqual(e1, e2)
def test_not_equal_to_non_check(self):
e = Error("Error", obj=DummyObj())
self.assertNotEqual(e, 'a string')
def simple_system_check(**kwargs):
simple_system_check.kwargs = kwargs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment