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

Method test_proxy_super

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

Source from the content-addressed store, hash-verified

4676 self.assertIsInstance(pa, C) # Test
4677
4678 def test_proxy_super(self):
4679 # Testing super() for a proxy object...
4680 class Proxy(object):
4681 def __init__(self, obj):
4682 self.__obj = obj
4683 def __getattribute__(self, name):
4684 if name.startswith("_Proxy__"):
4685 return object.__getattribute__(self, name)
4686 else:
4687 return getattr(self.__obj, name)
4688
4689 class B(object):
4690 def f(self):
4691 return "B.f"
4692
4693 class C(B):
4694 def f(self):
4695 return super(C, self).f() + "->C.f"
4696
4697 obj = C()
4698 p = Proxy(obj)
4699 self.assertEqual(C.__dict__["f"](p), "B.f->C.f")
4700
4701 def test_carloverre(self):
4702 # Testing prohibition of Carlo Verre's hack...

Callers

nothing calls this directly

Calls 3

CClass · 0.70
ProxyClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected