MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_classic

Method test_classic

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

Source from the content-addressed store, hash-verified

1766 self.assertEqual(d, d1)
1767
1768 def test_classic(self):
1769 # Testing classic classes...
1770 class C:
1771 def foo(*a): return a
1772 goo = classmethod(foo)
1773 c = C()
1774 self.assertEqual(C.goo(1), (C, 1))
1775 self.assertEqual(c.goo(1), (C, 1))
1776 self.assertEqual(c.foo(1), (c, 1))
1777 class D(C):
1778 pass
1779 d = D()
1780 self.assertEqual(D.goo(1), (D, 1))
1781 self.assertEqual(d.goo(1), (D, 1))
1782 self.assertEqual(d.foo(1), (d, 1))
1783 self.assertEqual(D.foo(d, 1), (d, 1))
1784 class E: # *not* subclassing from C
1785 foo = C.foo
1786 self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound
1787 self.assertStartsWith(repr(C.foo.__get__(C())), "<bound method ")
1788
1789 def test_compattr(self):
1790 # Testing computed attributes...

Callers

nothing calls this directly

Calls 9

fooMethod · 0.95
fooMethod · 0.95
reprFunction · 0.85
CClass · 0.70
DClass · 0.70
EClass · 0.70
assertEqualMethod · 0.45
assertStartsWithMethod · 0.45
__get__Method · 0.45

Tested by

no test coverage detected