Skip to content

Commit

Permalink
add test for slotted classes
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt committed Jul 5, 2023
1 parent abd1628 commit 4e068d4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Lib/test/test_functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,26 @@ def _(arg):
self.assertTrue(A.t(''))
self.assertEqual(A.t(0.0), 0.0)

def test_staticmethod__slotted_class(self):
class A:
__slots__ = ['a']
@functools.singledispatchmethod
def t(arg):
return arg
@t.register(int)
@staticmethod
def _(arg):
return isinstance(arg, int)
@t.register(str)
@staticmethod
def _(arg):
return isinstance(arg, str)
a = A()

self.assertTrue(A.t(0))
self.assertTrue(A.t(''))
self.assertEqual(A.t(0.0), 0.0)

def test_classmethod_register(self):
class A:
def __init__(self, arg):
Expand Down

0 comments on commit 4e068d4

Please sign in to comment.