Fix != operations on lazy objects.
This commit is contained in:
parent
59d127e45f
commit
714161c864
|
@ -346,6 +346,7 @@ class SimpleLazyObject(LazyObject):
|
||||||
# care about this (especially in equality tests)
|
# care about this (especially in equality tests)
|
||||||
__class__ = property(new_method_proxy(operator.attrgetter("__class__")))
|
__class__ = property(new_method_proxy(operator.attrgetter("__class__")))
|
||||||
__eq__ = new_method_proxy(operator.eq)
|
__eq__ = new_method_proxy(operator.eq)
|
||||||
|
__ne__ = new_method_proxy(operator.ne)
|
||||||
__hash__ = new_method_proxy(hash)
|
__hash__ = new_method_proxy(hash)
|
||||||
__bool__ = new_method_proxy(bool) # Python 3
|
__bool__ = new_method_proxy(bool) # Python 3
|
||||||
__nonzero__ = __bool__ # Python 2
|
__nonzero__ = __bool__ # Python 2
|
||||||
|
|
|
@ -152,3 +152,12 @@ class TestUtilsSimpleLazyObject(TestCase):
|
||||||
SimpleLazyObject(None)
|
SimpleLazyObject(None)
|
||||||
finally:
|
finally:
|
||||||
sys.settrace(old_trace_func)
|
sys.settrace(old_trace_func)
|
||||||
|
|
||||||
|
def test_not_equal(self):
|
||||||
|
lazy1 = SimpleLazyObject(lambda: 2)
|
||||||
|
lazy2 = SimpleLazyObject(lambda: 2)
|
||||||
|
lazy3 = SimpleLazyObject(lambda: 3)
|
||||||
|
self.assertEqual(lazy1, lazy2)
|
||||||
|
self.assertNotEqual(lazy1, lazy3)
|
||||||
|
self.assertTrue(lazy1 != lazy3)
|
||||||
|
self.assertFalse(lazy1 != lazy2)
|
||||||
|
|
Loading…
Reference in New Issue