Skip to content

Commit ec01821

Browse files
committed
Add precedent case for GH-84644
1 parent 44b8bba commit ec01821

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
@@ -3274,6 +3274,22 @@ def _(arg, extra: int):
32743274
"Use either `@register(some_class)` or add a type annotation "
32753275
f"to parameter 'arg' of your callable.")
32763276

3277+
with self.assertRaises(TypeError) as exc:
3278+
# See GH-84644.
3279+
3280+
@functools.singledispatch
3281+
def func(arg):...
3282+
3283+
@func.register
3284+
def _int(arg) -> int:...
3285+
3286+
self.assertStartsWith(str(exc.exception), msg_prefix +
3287+
"<function TestSingleDispatch.test_invalid_registrations.<locals>._"
3288+
)
3289+
self.assertEndsWith(str(exc.exception),
3290+
"Use either `@register(some_class)` or add a type annotation "
3291+
f"to parameter 'arg' of your callable.")
3292+
32773293
with self.assertRaises(TypeError) as exc:
32783294
@i.register
32793295
def _(arg: typing.Iterable[str]):

0 commit comments

Comments
 (0)