]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-96478: Test `@overload` on C functions (GH-96479)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 21 Sep 2022 01:36:23 +0000 (18:36 -0700)
committerGitHub <noreply@github.com>
Wed, 21 Sep 2022 01:36:23 +0000 (18:36 -0700)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit f177f6f29b069f522a0b3ba44eaae19852b6d2b0)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_typing.py

index 776a6f003c06913aee1d0edfd469fa95838f46fa..7df7e3ceb6803d3e56e4e9e600a467d7952794e5 100644 (file)
@@ -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