mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-106368: Increase Argument Clinic test coverage (#106728)
- improve output_parameter() coverage - improve coverage for Function.kind
This commit is contained in:
parent
f014f1567c
commit
ec45c513d3
2 changed files with 590 additions and 0 deletions
|
@ -1013,6 +1013,43 @@ class ClinicParserTest(TestCase):
|
|||
out = self.parse_function_should_fail(block)
|
||||
self.assertEqual(out, expected_error_msg)
|
||||
|
||||
def test_slot_methods_cannot_access_defining_class(self):
|
||||
block = """
|
||||
module foo
|
||||
class Foo "" ""
|
||||
Foo.__init__
|
||||
cls: defining_class
|
||||
a: object
|
||||
"""
|
||||
msg = "Slot methods cannot access their defining class."
|
||||
with self.assertRaisesRegex(ValueError, msg):
|
||||
self.parse_function(block)
|
||||
|
||||
def test_new_must_be_a_class_method(self):
|
||||
expected_error_msg = (
|
||||
"Error on line 0:\n"
|
||||
"__new__ must be a class method!\n"
|
||||
)
|
||||
out = self.parse_function_should_fail("""
|
||||
module foo
|
||||
class Foo "" ""
|
||||
Foo.__new__
|
||||
""")
|
||||
self.assertEqual(out, expected_error_msg)
|
||||
|
||||
def test_init_must_be_a_normal_method(self):
|
||||
expected_error_msg = (
|
||||
"Error on line 0:\n"
|
||||
"__init__ must be a normal method, not a class or static method!\n"
|
||||
)
|
||||
out = self.parse_function_should_fail("""
|
||||
module foo
|
||||
class Foo "" ""
|
||||
@classmethod
|
||||
Foo.__init__
|
||||
""")
|
||||
self.assertEqual(out, expected_error_msg)
|
||||
|
||||
def test_unused_param(self):
|
||||
block = self.parse("""
|
||||
module foo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue