MCPcopy Index your code
hub / github.com/python/cpython / test_isinst_isclass

Method test_isinst_isclass

Lib/test/test_descr.py:4639–4676  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4637 self.fail("shouldn't have allowed descr.__get__(None, int)")
4638
4639 def test_isinst_isclass(self):
4640 # Testing proxy isinstance() and isclass()...
4641 class Proxy(object):
4642 def __init__(self, obj):
4643 self.__obj = obj
4644 def __getattribute__(self, name):
4645 if name.startswith("_Proxy__"):
4646 return object.__getattribute__(self, name)
4647 else:
4648 return getattr(self.__obj, name)
4649 # Test with a classic class
4650 class C:
4651 pass
4652 a = C()
4653 pa = Proxy(a)
4654 self.assertIsInstance(a, C) # Baseline
4655 self.assertIsInstance(pa, C) # Test
4656 # Test with a classic subclass
4657 class D(C):
4658 pass
4659 a = D()
4660 pa = Proxy(a)
4661 self.assertIsInstance(a, C) # Baseline
4662 self.assertIsInstance(pa, C) # Test
4663 # Test with a new-style class
4664 class C(object):
4665 pass
4666 a = C()
4667 pa = Proxy(a)
4668 self.assertIsInstance(a, C) # Baseline
4669 self.assertIsInstance(pa, C) # Test
4670 # Test with a new-style subclass
4671 class D(C):
4672 pass
4673 a = D()
4674 pa = Proxy(a)
4675 self.assertIsInstance(a, C) # Baseline
4676 self.assertIsInstance(pa, C) # Test
4677
4678 def test_proxy_super(self):
4679 # Testing super() for a proxy object...

Callers

nothing calls this directly

Calls 4

assertIsInstanceMethod · 0.80
CClass · 0.70
ProxyClass · 0.70
DClass · 0.70

Tested by

no test coverage detected