Skip to content

Commit 3b5a410

Browse files
pR0Psjohnslavik
andcommitted
Add regrtest from @pR0Ps
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
1 parent 4c43a9c commit 3b5a410

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_functools.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,22 @@ def __eq__(self, other):
27212721
return self.arg == other
27222722
self.assertEqual(i("str"), "str")
27232723

2724+
def test_annotations_positional_only(self):
2725+
"""Regression test for GH-143888."""
2726+
@functools.singledispatch
2727+
def f(arg, /, extra):
2728+
return "base"
2729+
@f.register
2730+
def f_int(arg: int, /, extra: str):
2731+
return "int"
2732+
@f.register
2733+
def f_str(arg: str, /, extra: int):
2734+
return "str"
2735+
2736+
self.assertEqual(f(None, "extra"), "base")
2737+
self.assertEqual(f(1, "extra"), "int")
2738+
self.assertEqual(f("s", "extra"), "str")
2739+
27242740
def test_method_register(self):
27252741
class A:
27262742
@functools.singledispatchmethod

0 commit comments

Comments
 (0)