def test_hash(self): a = object() lazy_a1 = LazyObject(lambda: a) lazy_a2 = LazyObject(lambda: a) b = object() lazy_b1 = LazyObject(lambda: b) lazy_b2 = LazyObject(lambda: b) assert {a, lazy_a1, lazy_a2} == {a} assert {b, lazy_b1, lazy_b2} == {b} assert {lazy_a1, lazy_b2} == {a, b}
def hash_test(self): a = object() lazy_a1 = LazyObject(lambda: a) lazy_a2 = LazyObject(lambda: a) b = object() lazy_b1 = LazyObject(lambda: b) lazy_b2 = LazyObject(lambda: b) self.assertEqual({a, lazy_a1, lazy_a2}, {a}) self.assertEqual({b, lazy_b1, lazy_b2}, {b}) self.assertEqual({lazy_a1, lazy_b2}, {a, b})
def test_neq(self): a = object() lazy_a = LazyObject(lambda: a) b = object() lazy_b = LazyObject(lambda: b) assert b != lazy_a assert lazy_a != b assert lazy_a != lazy_b assert lazy_b != lazy_a
def neq_test(self): a = object() lazy_a = LazyObject(lambda: a) b = object() lazy_b = LazyObject(lambda: b) self.assertNotEqual(b, lazy_a) self.assertNotEqual(lazy_a, b) self.assertNotEqual(lazy_a, lazy_b) self.assertNotEqual(lazy_b, lazy_a)
def test_eq(self): a = object() lazy_a1 = LazyObject(lambda: a) lazy_a2 = LazyObject(lambda: a) assert a == lazy_a1 assert lazy_a1 == a assert a == lazy_a2 assert lazy_a2 == a assert lazy_a1 == lazy_a2 assert lazy_a2 == lazy_a1 assert lazy_a1 == lazy_a1 assert lazy_a2 == lazy_a2
def eq_test(self): a = object() lazy_a1 = LazyObject(lambda: a) lazy_a2 = LazyObject(lambda: a) self.assertEqual(a, lazy_a1) self.assertEqual(lazy_a1, a) self.assertEqual(a, lazy_a2) self.assertEqual(lazy_a2, a) self.assertEqual(lazy_a1, lazy_a2) self.assertEqual(lazy_a2, lazy_a1) self.assertEqual(lazy_a1, lazy_a1) self.assertEqual(lazy_a2, lazy_a2)
def lazy_storage(self): """The lazy storage model. Provides a lazy access to the storage model. This property will not trigger a creation of the storage playground. The playground will be created on the first access of the storage attributes. """ return LazyObject(lambda: self.storage)
def lazy_obj(self): return LazyObject(lambda: self.obj)