]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106368: Argument Clinic: Test that keyword params are disallowed in groups (#107985)
authorErlend E. Aasland <erlend@python.org>
Wed, 16 Aug 2023 10:39:56 +0000 (12:39 +0200)
committerGitHub <noreply@github.com>
Wed, 16 Aug 2023 10:39:56 +0000 (12:39 +0200)
Lib/test/test_clinic.py

index 76729c8c3e4f791792b2501bb5682052ed43d1c4..32aac407a028c956c7a7d189391112d135bb3945 100644 (file)
@@ -1524,6 +1524,27 @@ class ClinicParserTest(TestCase):
         err = "Function 'empty_group' has a ']' without a matching '['"
         self.expect_failure(block, err)
 
+    def test_disallowed_grouping__must_be_position_only(self):
+        dataset = ("""
+            with_kwds
+                [
+                *
+                a: object
+                ]
+        """, """
+            with_kwds
+                [
+                a: object
+                ]
+        """)
+        err = (
+            "You cannot use optional groups ('[' and ']') unless all "
+            "parameters are positional-only ('/')"
+        )
+        for block in dataset:
+            with self.subTest(block=block):
+                self.expect_failure(block, err)
+
     def test_no_parameters(self):
         function = self.parse_function("""
             module foo