Kaydet (Commit) a0d63b02 authored tarafından Javier Buzzi's avatar Javier Buzzi Kaydeden (comit) Tim Graham

Fixed #29772 -- Made LazyObject proxy __lt__() and __gt__().

üst 9cbdb440
......@@ -304,6 +304,8 @@ class LazyObject:
# care about this (especially in equality tests)
__class__ = property(new_method_proxy(operator.attrgetter("__class__")))
__eq__ = new_method_proxy(operator.eq)
__lt__ = new_method_proxy(operator.lt)
__gt__ = new_method_proxy(operator.gt)
__ne__ = new_method_proxy(operator.ne)
__hash__ = new_method_proxy(hash)
......
......@@ -66,6 +66,16 @@ class LazyObjectTestCase(TestCase):
self.assertNotEqual(obj1, obj2)
self.assertNotEqual(obj1, 'bar')
def test_lt(self):
obj1 = self.lazy_wrap(1)
obj2 = self.lazy_wrap(2)
self.assertLess(obj1, obj2)
def test_gt(self):
obj1 = self.lazy_wrap(1)
obj2 = self.lazy_wrap(2)
self.assertGreater(obj2, obj1)
def test_bytes(self):
obj = self.lazy_wrap(b'foo')
self.assertEqual(bytes(obj), b'foo')
......
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