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

Method test_methods

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

Source from the content-addressed store, hash-verified

2144 self.assertEqual(number_attrs(Numbers()), list(range(280)))
2145
2146 def test_methods(self):
2147 # Testing methods...
2148 class C(object):
2149 def __init__(self, x):
2150 self.x = x
2151 def foo(self):
2152 return self.x
2153 c1 = C(1)
2154 self.assertEqual(c1.foo(), 1)
2155 class D(C):
2156 boo = C.foo
2157 goo = c1.foo
2158 d2 = D(2)
2159 self.assertEqual(d2.foo(), 2)
2160 self.assertEqual(d2.boo(), 2)
2161 self.assertEqual(d2.goo(), 1)
2162 class E(object):
2163 foo = C.foo
2164 self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound
2165 self.assertStartsWith(repr(C.foo.__get__(C(1))), "<bound method ")
2166
2167 @support.impl_detail("testing error message from implementation")
2168 def test_methods_in_c(self):

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected