Skip to content

Commit c77c412

Browse files
Add tests for a bare ** and for var-positional in an optional group
1 parent 66697ca commit c77c412

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

Lib/test/test_clinic.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def test_vararg_after_star(self):
377377
"""
378378
self.expect_failure(block, err, lineno=6)
379379

380-
def test_double_star_after_var_keyword(self):
380+
def test_parameter_after_var_keyword(self):
381381
err = "parameters cannot follow var-keyword parameter: 'invalid_arg: object'"
382382
block = """
383383
/*[clinic input]
@@ -389,6 +389,18 @@ def test_double_star_after_var_keyword(self):
389389
"""
390390
self.expect_failure(block, err, lineno=5)
391391

392+
def test_double_star_without_name(self):
393+
err = "Function 'my_test_func' has an invalid parameter declaration: '**'"
394+
block = """
395+
/*[clinic input]
396+
my_test_func
397+
398+
pos_arg: object
399+
**
400+
[clinic start generated code]*/
401+
"""
402+
self.expect_failure(block, err, lineno=5)
403+
392404
def test_module_already_got_one(self):
393405
err = "Already defined module 'm'!"
394406
block = """
@@ -2403,6 +2415,17 @@ def test_group_with_var_keyword(self):
24032415
err = "parameters cannot follow var-keyword parameter: ']'"
24042416
self.expect_failure(block, err)
24052417

2418+
def test_group_with_var_positional(self):
2419+
block = """
2420+
with_varpos
2421+
[
2422+
*args: tuple
2423+
]
2424+
"""
2425+
err = ("You cannot use optional groups ('[' and ']') unless all "
2426+
"parameters are positional-only ('/')")
2427+
self.expect_failure(block, err)
2428+
24062429
def test_depr_star_must_come_after_slash(self):
24072430
block = """
24082431
module foo

0 commit comments

Comments
 (0)