summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorneonene <53406459+neonene@users.noreply.github.com>2024-04-17 21:11:17 (GMT)
committerGitHub <noreply@github.com>2024-04-17 21:11:17 (GMT)
commit9f4ae13d2a432faa80e76e3948aec43f856fd320 (patch)
tree6e9d677c5199edfb403a09c8ad91d4ca4cc2fcdd /Lib/test
parenta72c4a93ef2babb6f49a5b8869bc6c40997df081 (diff)
downloadcpython-9f4ae13d2a432faa80e76e3948aec43f856fd320.zip
cpython-9f4ae13d2a432faa80e76e3948aec43f856fd320.tar.gz
cpython-9f4ae13d2a432faa80e76e3948aec43f856fd320.tar.bz2
[3.12] gh-117613: Argument Clinic: ensure that defining class params are positional-only (#117939)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_clinic.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 3a0ff94..c114a62 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -1347,6 +1347,28 @@ class ClinicParserTest(_ParserBase):
parser_decl = p.simple_declaration(in_parser=True)
self.assertNotIn("Py_UNUSED", parser_decl)
+ def test_kind_defining_class(self):
+ function = self.parse_function("""
+ module m
+ class m.C "PyObject *" ""
+ m.C.meth
+ cls: defining_class
+ """, signatures_in_block=3, function_index=2)
+ p = function.parameters['cls']
+ self.assertEqual(p.kind, inspect.Parameter.POSITIONAL_ONLY)
+
+ def test_disallow_defining_class_at_module_level(self):
+ expected_error_msg = (
+ "Error on line 0:\n"
+ "A 'defining_class' parameter cannot be defined at module level.\n"
+ )
+ out = self.parse_function_should_fail("""
+ module m
+ m.func
+ cls: defining_class
+ """)
+ self.assertEqual(out, expected_error_msg)
+
def parse(self, text):
c = FakeClinic()
parser = DSLParser(c)