8000 add test for slotted classes · python/cpython@4e068d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e068d4

Browse files
committed
add test for slotted classes
1 parent abd1628 commit 4e068d4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Lib/test/test_functools.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,26 @@ def _(arg):
24742474
self.assertTrue(A.t(''))
24752475
self.assertEqual(A.t(0.0), 0.0)
24762476

2477+
def test_staticmethod__slotted_class(self):
2478+
class A:
2479+
__slots__ = ['a']
2480+
@functools.singledispatchmethod
2481+
def t(arg):
2482+
return arg
2483+
@t.register(int)
2484+
@staticmethod
2485+
def _(arg):
2486+
return isinstance(arg, int)
2487+
@t.register(str)
2488+
@staticmethod
2489+
def _(arg):
2490+
return isinstance(arg, str)
2491+
a = A()
2492+
2493+
self.assertTrue(A.t(0))
2494+
self.assertTrue(A.t(''))
2495+
self.assertEqual(A.t(0.0), 0.0)
2496+
24772497
def test_classmethod_register(self):
24782498
class A:
24792499
def __init__(self, arg):

0 commit comments

Comments
 (0)
0