8000 gh-95065: Argument Clinic: Add functional tests of deprecated positionals by erlend-aasland · Pull Request #107768 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-95065: Argument Clinic: Add functional tests of deprecated positionals #107768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
erlend-aasland and serhiy-storchaka authored Aug 10, 2023
commit e56888c400d1edc0dd64f3a4c9f4c98f94d78663
8 changes: 5 additions & 3 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2436,7 +2436,7 @@ def check_depr_star(self, pnames, fn, *args, **kwds):
regex = (
fr"Passing( more than)?( [0-9]+)? positional argument(s)? to "
fr"{fn.__name__}\(\) is deprecated. Parameter(s)? {pnames} will "
fr"become( a)? keyword-only parameter(s)? in Python 3.14"
fr"become( a)? keyword-only parameter(s)? in Python 3\.14"
)
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
# Record the line number, so we're sure we've got the correct stack
Expand Down Expand Up @@ -2915,17 +2915,19 @@ def test_depr_star_new(self):
"deprecated. Parameter 'a' will become a keyword-only parameter "
"in Python 3.14."
)
with self.assertWarnsRegex(DeprecationWarning, regex):
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
ac_tester.DeprStarNew(None)
self.assertEqual(cm.filename, __file__)

def test_depr_star_init(self):
regex = re.escape(
"Passing positional arguments to _testclinic.DeprStarInit() is "
"deprecated. Parameter 'a' will become a keyword-only parameter "
"in Python 3.14."
)
with self.assertWarnsRegex(DeprecationWarning, regex):
with self.assertWarnsRegex(DeprecationWarning, regex) as cm:
ac_tester.DeprStarInit(None)
self.assertEqual(cm.filename, __file__)

def test_depr_star_pos0_len1(self):
fn = ac_tester.depr_star_pos0_len1
Expand Down
6 changes: 1 addition & 5 deletions Modules/_testclinic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1227,11 +1227,7 @@ static PyObject *
depr_star_new_impl(PyTypeObject *type, PyObject *a)
/*[clinic end generated code: output=bdbb36244f90cf46 input=f4ae7dafbc23c378]*/
{
PyObject *self = type->tp_alloc(type, 0);
if (self == NULL) {
return NULL;
}
return self;
return type->tp_alloc(type, 0);
}

static PyTypeObject DeprStarNew = {
Expand Down
0