Skip to content

Commit ef74667

Browse files
committed
Restore old tests
1 parent 9191a22 commit ef74667

File tree

1 file changed

+1
-64
lines changed

1 file changed

+1
-64
lines changed

Lib/test/test_functools.py

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,34 +2905,13 @@ def t(self, arg):
29052905
def _(self, arg: int):
29062906
return "int"
29072907
@t.register
2908-
def _(self, arg: complex, /):
2909-
return "complex"
2910-
@t.register
2911-
def _(self, /, arg: str):
2908+
def _(self, arg: str):
29122909
return "str"
2913-
# See GH-130827.
2914-
def wrapped1(self: typing.Self, arg: bytes):
2915-
return "bytes"
2916-
@t.register
2917-
@functools.wraps(wrapped1)
2918-
def wrapper1(self, *args, **kwargs):
2919-
return self.wrapped1(*args, **kwargs)
2920-
2921-
def wrapped2(self, arg: bytearray) -> str:
2922-
return "bytearray"
2923-
@t.register
2924-
@functools.wraps(wrapped2)
2925-
def wrapper2(self, *args: typing.Any, **kwargs: typing.Any):
2926-
return self.wrapped2(*args, **kwargs)
2927-
29282910
a = A()
29292911

29302912
self.assertEqual(a.t(0), "int")
2931-
self.assertEqual(a.t(0j), "complex")
29322913
self.assertEqual(a.t(''), "str")
29332914
self.assertEqual(a.t(0.0), "base")
2934-
self.assertEqual(a.t(b''), "bytes")
2935-
self.assertEqual(a.t(bytearray()), "bytearray")
29362915

29372916
def test_staticmethod_type_ann_register(self):
29382917
class A:
@@ -3193,27 +3172,12 @@ def test_invalid_registrations(self):
31933172
@functools.singledispatch
31943173
def i(arg):
31953174
return "base"
3196-
with self.assertRaises(TypeError) as exc:
3197-
@i.register
3198-
def _() -> None:
3199-
return "My function doesn't take arguments"
3200-
self.assertStartsWith(str(exc.exception), msg_prefix)
3201-
self.assertEndsWith(str(exc.exception), "does not accept positional arguments.")
3202-
3203-
with self.assertRaises(TypeError) as exc:
3204-
@i.register
3205-
def _(*, foo: str) -> None:
3206-
return "My function takes keyword-only arguments"
3207-
self.assertStartsWith(str(exc.exception), msg_prefix)
3208-
self.assertEndsWith(str(exc.exception), "does not accept positional arguments.")
3209-
32103175
with self.assertRaises(TypeError) as exc:
32113176
@i.register(42)
32123177
def _(arg):
32133178
return "I annotated with a non-type"
32143179
self.assertStartsWith(str(exc.exception), msg_prefix + "42")
32153180
self.assertEndsWith(str(exc.exception), msg_suffix)
3216-
32173181
with self.assertRaises(TypeError) as exc:
32183182
@i.register
32193183
def _(arg):
@@ -3223,33 +3187,6 @@ def _(arg):
32233187
)
32243188
self.assertEndsWith(str(exc.exception), msg_suffix)
32253189

3226-
with self.assertRaises(TypeError) as exc:
3227-
@i.register
3228-
def _(arg, extra: int):
3229-
return "I did not annotate the right param"
3230-
self.assertStartsWith(str(exc.exception), msg_prefix +
3231-
"<function TestSingleDispatch.test_invalid_registrations.<locals>._"
3232-
)
3233-
self.assertEndsWith(str(exc.exception),
3234-
"Use either `@register(some_class)` or add a type annotation "
3235-
f"to parameter 'arg' of your callable.")
3236-
3237-
with self.assertRaises(TypeError) as exc:
3238-
# See GH-84644.
3239-
3240-
@functools.singledispatch
3241-
def func(arg):...
3242-
3243-
@func.register
3244-
def _int(arg) -> int:...
3245-
3246-
self.assertStartsWith(str(exc.exception), msg_prefix +
3247-
"<function TestSingleDispatch.test_invalid_registrations.<locals>._int"
3248-
)
3249-
self.assertEndsWith(str(exc.exception),
3250-
"Use either `@register(some_class)` or add a type annotation "
3251-
f"to parameter 'arg' of your callable.")
3252-
32533190
with self.assertRaises(TypeError) as exc:
32543191
@i.register
32553192
def _(arg: typing.Iterable[str]):

0 commit comments

Comments
 (0)