From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 21 Sep 2022 01:36:23 +0000 (-0700) Subject: gh-96478: Test `@overload` on C functions (GH-96479) X-Git-Tag: v3.11.1~461 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2a5e3337367b4636802697f8e5c78bc5382ec8cb;p=thirdparty%2FPython%2Fcpython.git gh-96478: Test `@overload` on C functions (GH-96479) Co-authored-by: Alex Waygood (cherry picked from commit f177f6f29b069f522a0b3ba44eaae19852b6d2b0) Co-authored-by: Nikita Sobolev --- diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 776a6f003c06..7df7e3ceb680 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -4379,6 +4379,20 @@ class OverloadTests(BaseTestCase): blah() + @patch("typing._overload_registry", + defaultdict(lambda: defaultdict(dict))) + def test_overload_on_compiled_functions(self): + # The registry starts out empty: + self.assertEqual(typing._overload_registry, {}) + + # This should just not fail: + overload(sum) + overload(print) + + # No overloads are recorded (but, it still has a side-effect): + self.assertEqual(typing.get_overloads(sum), []) + self.assertEqual(typing.get_overloads(print), []) + def set_up_overloads(self): def blah(): pass