MCPcopy Create free account
hub / github.com/bpython/bpython / test_lookup_on_object

Method test_lookup_on_object

bpython/test/test_inspection.py:307–319  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

305
306class TestSafeGetAttribute(unittest.TestCase):
307 def test_lookup_on_object(self):
308 a = A()
309 a.x = 1
310 self.assertEqual(inspection.getattr_safe(a, "x"), 1)
311 self.assertEqual(inspection.getattr_safe(a, "a"), "a")
312 b = B()
313 b.y = 2
314 self.assertEqual(inspection.getattr_safe(b, "y"), 2)
315 self.assertEqual(inspection.getattr_safe(b, "a"), "a")
316 self.assertEqual(inspection.getattr_safe(b, "b"), "b")
317
318 self.assertEqual(inspection.hasattr_safe(b, "y"), True)
319 self.assertEqual(inspection.hasattr_safe(b, "b"), True)
320
321 def test_avoid_running_properties(self):
322 p = Property()

Callers

nothing calls this directly

Calls 2

AClass · 0.85
BClass · 0.85

Tested by

no test coverage detected