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

Method test_staticmethods

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

Source from the content-addressed store, hash-verified

1717 self.assertEqual(str(cm.exception), expected_errmsg)
1718
1719 def test_staticmethods(self):
1720 # Testing static methods...
1721 class C(object):
1722 def foo(*a): return a
1723 goo = staticmethod(foo)
1724 c = C()
1725 self.assertEqual(C.goo(1), (1,))
1726 self.assertEqual(c.goo(1), (1,))
1727 self.assertEqual(c.foo(1), (c, 1,))
1728 class D(C):
1729 pass
1730 d = D()
1731 self.assertEqual(D.goo(1), (1,))
1732 self.assertEqual(d.goo(1), (1,))
1733 self.assertEqual(d.foo(1), (d, 1))
1734 self.assertEqual(D.foo(d, 1), (d, 1))
1735 sm = staticmethod(None)
1736 self.assertEqual(sm.__dict__, {'__doc__': None.__doc__})
1737 sm.x = 42
1738 self.assertEqual(sm.x, 42)
1739 self.assertEqual(sm.__dict__, {"x" : 42, '__doc__': None.__doc__})
1740 del sm.x
1741 self.assertNotHasAttr(sm, "x")
1742
1743 @support.refcount_test
1744 def test_refleaks_in_staticmethod___init__(self):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected