Skip to content

Commit 57a20b0

Browse files
gh-106368: Argument Clinic: Test that keyword params are disallowed in groups (#107985)
1 parent bdd8ddf commit 57a20b0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Lib/test/test_clinic.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,27 @@ def test_disallowed_grouping__no_matching_bracket(self):
15241524
err = "Function 'empty_group' has a ']' without a matching '['"
15251525
self.expect_failure(block, err)
15261526

1527+
def test_disallowed_grouping__must_be_position_only(self):
1528+
dataset = ("""
1529+
with_kwds
1530+
[
1531+
*
1532+
a: object
1533+
]
1534+
""", """
1535+
with_kwds
1536+
[
1537+
a: object
1538+
]
1539+
""")
1540+
err = (
1541+
"You cannot use optional groups ('[' and ']') unless all "
1542+
"parameters are positional-only ('/')"
1543+
)
1544+
for block in dataset:
1545+
with self.subTest(block=block):
1546+
self.expect_failure(block, err)
1547+
15271548
def test_no_parameters(self):
15281549
function = self.parse_function("""
15291550
module foo

0 commit comments

Comments
 (0)