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

Method test_staticmethod_register

Lib/test/test_functools.py:2821–2839  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2819 self.assertNotHasAttr(aa, 'arg')
2820
2821 def test_staticmethod_register(self):
2822 class A:
2823 @functools.singledispatchmethod
2824 @staticmethod
2825 def t(arg):
2826 return arg
2827 @t.register(int)
2828 @staticmethod
2829 def _(arg):
2830 return isinstance(arg, int)
2831 @t.register(str)
2832 @staticmethod
2833 def _(arg):
2834 return isinstance(arg, str)
2835 a = A()
2836
2837 self.assertTrue(A.t(0))
2838 self.assertTrue(A.t(''))
2839 self.assertEqual(A.t(0.0), 0.0)
2840
2841 def test_slotted_class(self):
2842 class Slot:

Callers

nothing calls this directly

Calls 4

assertTrueMethod · 0.80
AClass · 0.70
tMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected