gh-107880: Teach Argument Clinic to clone __init__ and __new__ methods (#107885)

This commit is contained in:
Erlend E. Aasland 2023-08-13 12:13:11 +02:00 committed by GitHub
parent 7ddc1eaff1
commit 9b75ada6e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 244 additions and 8 deletions

View file

@ -2973,6 +2973,17 @@ class ClinicFunctionalTest(unittest.TestCase):
ac_tester.DeprStarNew(None)
self.assertEqual(cm.filename, __file__)
def test_depr_star_new_cloned(self):
regex = re.escape(
"Passing positional arguments to _testclinic.DeprStarNew.cloned() "
"is deprecated. Parameter 'a' will become a keyword-only parameter "
"in Python 3.14."
)
obj = ac_tester.DeprStarNew(a=None)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
obj.cloned(None)
self.assertEqual(cm.filename, __file__)
def test_depr_star_init(self):
regex = re.escape(
"Passing positional arguments to _testclinic.DeprStarInit() is "
@ -2983,6 +2994,17 @@ class ClinicFunctionalTest(unittest.TestCase):
ac_tester.DeprStarInit(None)
self.assertEqual(cm.filename, __file__)
def test_depr_star_init_cloned(self):
regex = re.escape(
"Passing positional arguments to _testclinic.DeprStarInit.cloned() "
"is deprecated. Parameter 'a' will become a keyword-only parameter "
"in Python 3.14."
)
obj = ac_tester.DeprStarInit(a=None)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
obj.cloned(None)
self.assertEqual(cm.filename, __file__)
def test_depr_star_pos0_len1(self):
fn = ac_tester.depr_star_pos0_len1
fn(a=None)