aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_clinic.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_clinic.py')
-rw-r--r--Lib/test/test_clinic.py51
1 files changed, 24 insertions, 27 deletions
diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py
index 0c99620e27c..580d54e0eb0 100644
--- a/Lib/test/test_clinic.py
+++ b/Lib/test/test_clinic.py
@@ -238,11 +238,11 @@ class ClinicWholeFileTest(TestCase):
# The generated output will differ for every run, but we can check that
# it starts with the clinic block, we check that it contains all the
# expected fields, and we check that it contains the checksum line.
- self.assertTrue(out.startswith(dedent("""
+ self.assertStartsWith(out, dedent("""
/*[clinic input]
output print 'I told you once.'
[clinic start generated code]*/
- """)))
+ """))
fields = {
"cpp_endif",
"cpp_if",
@@ -259,9 +259,7 @@ class ClinicWholeFileTest(TestCase):
with self.subTest(field=field):
self.assertIn(field, out)
last_line = out.rstrip().split("\n")[-1]
- self.assertTrue(
- last_line.startswith("/*[clinic end generated code: output=")
- )
+ self.assertStartsWith(last_line, "/*[clinic end generated code: output=")
def test_directive_wrong_arg_number(self):
raw = dedent("""
@@ -2705,8 +2703,7 @@ class ClinicExternalTest(TestCase):
# Note, we cannot check the entire fail msg, because the path to
# the tmp file will change for every run.
_, err = self.expect_failure(fn)
- self.assertTrue(err.endswith(fail_msg),
- f"{err!r} does not end with {fail_msg!r}")
+ self.assertEndsWith(err, fail_msg)
# Then, force regeneration; success expected.
out = self.expect_success("-f", fn)
self.assertEqual(out, "")
@@ -2717,8 +2714,7 @@ class ClinicExternalTest(TestCase):
)
with open(fn, encoding='utf-8') as f:
generated = f.read()
- self.assertTrue(generated.endswith(checksum),
- (generated, checksum))
+ self.assertEndsWith(generated, checksum)
def test_cli_make(self):
c_code = dedent("""
@@ -2835,6 +2831,10 @@ class ClinicExternalTest(TestCase):
"size_t",
"slice_index",
"str",
+ "uint16",
+ "uint32",
+ "uint64",
+ "uint8",
"unicode",
"unsigned_char",
"unsigned_int",
@@ -2863,8 +2863,8 @@ class ClinicExternalTest(TestCase):
# param may change (it's a set, thus unordered). So, let's compare the
# start and end of the expected output, and then assert that the
# converters appear lined up in alphabetical order.
- self.assertTrue(out.startswith(prelude), out)
- self.assertTrue(out.endswith(finale), out)
+ self.assertStartsWith(out, prelude)
+ self.assertEndsWith(out, finale)
out = out.removeprefix(prelude)
out = out.removesuffix(finale)
@@ -2872,10 +2872,7 @@ class ClinicExternalTest(TestCase):
for converter, line in zip(expected_converters, lines):
line = line.lstrip()
with self.subTest(converter=converter):
- self.assertTrue(
- line.startswith(converter),
- f"expected converter {converter!r}, got {line!r}"
- )
+ self.assertStartsWith(line, converter)
def test_cli_fail_converters_and_filename(self):
_, err = self.expect_failure("--converters", "test.c")
@@ -2985,7 +2982,7 @@ class ClinicFunctionalTest(unittest.TestCase):
regex = (
fr"Passing( more than)?( [0-9]+)? positional argument(s)? to "
fr"{re.escape(name)}\(\) is deprecated. Parameters? {pnames} will "
- fr"become( a)? keyword-only parameters? in Python 3\.14"
+ fr"become( a)? keyword-only parameters? in Python 3\.37"
)
self.check_depr(regex, fn, *args, **kwds)
@@ -2998,7 +2995,7 @@ class ClinicFunctionalTest(unittest.TestCase):
regex = (
fr"Passing keyword argument{pl} {pnames} to "
fr"{re.escape(name)}\(\) is deprecated. Parameter{pl} {pnames} "
- fr"will become positional-only in Python 3\.14."
+ fr"will become positional-only in Python 3\.37."
)
self.check_depr(regex, fn, *args, **kwds)
@@ -3782,9 +3779,9 @@ class ClinicFunctionalTest(unittest.TestCase):
fn("a", b="b", c="c", d="d", e="e", f="f", g="g", h="h")
errmsg = (
"Passing more than 1 positional argument to depr_star_multi() is deprecated. "
- "Parameter 'b' will become a keyword-only parameter in Python 3.16. "
- "Parameters 'c' and 'd' will become keyword-only parameters in Python 3.15. "
- "Parameters 'e', 'f' and 'g' will become keyword-only parameters in Python 3.14.")
+ "Parameter 'b' will become a keyword-only parameter in Python 3.39. "
+ "Parameters 'c' and 'd' will become keyword-only parameters in Python 3.38. "
+ "Parameters 'e', 'f' and 'g' will become keyword-only parameters in Python 3.37.")
check = partial(self.check_depr, re.escape(errmsg), fn)
check("a", "b", c="c", d="d", e="e", f="f", g="g", h="h")
check("a", "b", "c", d="d", e="e", f="f", g="g", h="h")
@@ -3883,9 +3880,9 @@ class ClinicFunctionalTest(unittest.TestCase):
fn("a", "b", "c", "d", "e", "f", "g", h="h")
errmsg = (
"Passing keyword arguments 'b', 'c', 'd', 'e', 'f' and 'g' to depr_kwd_multi() is deprecated. "
- "Parameter 'b' will become positional-only in Python 3.14. "
- "Parameters 'c' and 'd' will become positional-only in Python 3.15. "
- "Parameters 'e', 'f' and 'g' will become positional-only in Python 3.16.")
+ "Parameter 'b' will become positional-only in Python 3.37. "
+ "Parameters 'c' and 'd' will become positional-only in Python 3.38. "
+ "Parameters 'e', 'f' and 'g' will become positional-only in Python 3.39.")
check = partial(self.check_depr, re.escape(errmsg), fn)
check("a", "b", "c", "d", "e", "f", g="g", h="h")
check("a", "b", "c", "d", "e", f="f", g="g", h="h")
@@ -3900,8 +3897,8 @@ class ClinicFunctionalTest(unittest.TestCase):
self.assertRaises(TypeError, fn, "a", "b", "c", "d", "e", "f", "g")
errmsg = (
"Passing more than 4 positional arguments to depr_multi() is deprecated. "
- "Parameter 'e' will become a keyword-only parameter in Python 3.15. "
- "Parameter 'f' will become a keyword-only parameter in Python 3.14.")
+ "Parameter 'e' will become a keyword-only parameter in Python 3.38. "
+ "Parameter 'f' will become a keyword-only parameter in Python 3.37.")
check = partial(self.check_depr, re.escape(errmsg), fn)
check("a", "b", "c", "d", "e", "f", g="g")
check("a", "b", "c", "d", "e", f="f", g="g")
@@ -3909,8 +3906,8 @@ class ClinicFunctionalTest(unittest.TestCase):
fn("a", "b", "c", d="d", e="e", f="f", g="g")
errmsg = (
"Passing keyword arguments 'b' and 'c' to depr_multi() is deprecated. "
- "Parameter 'b' will become positional-only in Python 3.14. "
- "Parameter 'c' will become positional-only in Python 3.15.")
+ "Parameter 'b' will become positional-only in Python 3.37. "
+ "Parameter 'c' will become positional-only in Python 3.38.")
check = partial(self.check_depr, re.escape(errmsg), fn)
check("a", "b", c="c", d="d", e="e", f="f", g="g")
check("a", b="b", c="c", d="d", e="e", f="f", g="g")