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

Method test_classic

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

Source from the content-addressed store, hash-verified

1866 self.assertEqual(d, d1)
1867
1868 def test_classic(self):
1869 # Testing classic classes...
1870 class C:
1871 def foo(*a): return a
1872 goo = classmethod(foo)
1873 c = C()
1874 self.assertEqual(C.goo(1), (C, 1))
1875 self.assertEqual(c.goo(1), (C, 1))
1876 self.assertEqual(c.foo(1), (c, 1))
1877 class D(C):
1878 pass
1879 d = D()
1880 self.assertEqual(D.goo(1), (D, 1))
1881 self.assertEqual(d.goo(1), (D, 1))
1882 self.assertEqual(d.foo(1), (d, 1))
1883 self.assertEqual(D.foo(d, 1), (d, 1))
1884 class E: # *not* subclassing from C
1885 foo = C.foo
1886 self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound
1887 self.assertStartsWith(repr(C.foo.__get__(C())), "<bound method ")
1888
1889 def test_compattr(self):
1890 # Testing computed attributes...

Callers

nothing calls this directly

Calls 8

fooMethod · 0.95
fooMethod · 0.95
assertStartsWithMethod · 0.80
CClass · 0.70
DClass · 0.70
EClass · 0.70
assertEqualMethod · 0.45
__get__Method · 0.45

Tested by

no test coverage detected