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

Method test_methods

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

Source from the content-addressed store, hash-verified

2047 self.assertEqual(number_attrs(Numbers()), list(range(280)))
2048
2049 def test_methods(self):
2050 # Testing methods...
2051 class C(object):
2052 def __init__(self, x):
2053 self.x = x
2054 def foo(self):
2055 return self.x
2056 c1 = C(1)
2057 self.assertEqual(c1.foo(), 1)
2058 class D(C):
2059 boo = C.foo
2060 goo = c1.foo
2061 d2 = D(2)
2062 self.assertEqual(d2.foo(), 2)
2063 self.assertEqual(d2.boo(), 2)
2064 self.assertEqual(d2.goo(), 1)
2065 class E(object):
2066 foo = C.foo
2067 self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound
2068 self.assertStartsWith(repr(C.foo.__get__(C(1))), "<bound method ")
2069
2070 @support.impl_detail("testing error message from implementation")
2071 def test_methods_in_c(self):

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected