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

Method test_staticmethods

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

Source from the content-addressed store, hash-verified

1826 )
1827
1828 def test_staticmethods(self):
1829 # Testing static methods...
1830 class C(object):
1831 def foo(*a): return a
1832 goo = staticmethod(foo)
1833 c = C()
1834 self.assertEqual(C.goo(1), (1,))
1835 self.assertEqual(c.goo(1), (1,))
1836 self.assertEqual(c.foo(1), (c, 1,))
1837 class D(C):
1838 pass
1839 d = D()
1840 self.assertEqual(D.goo(1), (1,))
1841 self.assertEqual(d.goo(1), (1,))
1842 self.assertEqual(d.foo(1), (d, 1))
1843 self.assertEqual(D.foo(d, 1), (d, 1))
1844 sm = staticmethod(None)
1845 self.assertEqual(sm.__dict__, {'__doc__': None.__doc__})
1846 sm.x = 42
1847 self.assertEqual(sm.x, 42)
1848 self.assertEqual(sm.__dict__, {"x" : 42, '__doc__': None.__doc__})
1849 del sm.x
1850 self.assertNotHasAttr(sm, "x")
1851
1852 @support.impl_detail("the module 'xxsubtype' is internal")
1853 @unittest.skipIf(xxsubtype is None, "requires xxsubtype module")

Callers

nothing calls this directly

Calls 6

fooMethod · 0.95
fooMethod · 0.95
assertNotHasAttrMethod · 0.80
CClass · 0.70
DClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected