[3.14] gh-71339: Use new assertion methods in tests (GH-129046) (GH-134498)

(cherry picked from commit 2602d8ae98)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-05-22 12:42:50 +02:00 committed by GitHub
parent d5f7e80d44
commit db98e0bb12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
117 changed files with 407 additions and 445 deletions

View file

@ -39,7 +39,8 @@ class CmdLineTest(unittest.TestCase):
def verify_valid_flag(self, cmd_line):
rc, out, err = assert_python_ok(cmd_line)
self.assertTrue(out == b'' or out.endswith(b'\n'))
if out != b'':
self.assertEndsWith(out, b'\n')
self.assertNotIn(b'Traceback', out)
self.assertNotIn(b'Traceback', err)
return out
@ -89,8 +90,8 @@ class CmdLineTest(unittest.TestCase):
version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
for switch in '-V', '--version', '-VV':
rc, out, err = assert_python_ok(switch)
self.assertFalse(err.startswith(version))
self.assertTrue(out.startswith(version))
self.assertNotStartsWith(err, version)
self.assertStartsWith(out, version)
def test_verbose(self):
# -v causes imports to write to stderr. If the write to
@ -380,7 +381,7 @@ class CmdLineTest(unittest.TestCase):
p.stdin.flush()
data, rc = _kill_python_and_exit_code(p)
self.assertEqual(rc, 0)
self.assertTrue(data.startswith(b'x'), data)
self.assertStartsWith(data, b'x')
def test_large_PYTHONPATH(self):
path1 = "ABCDE" * 100
@ -1039,7 +1040,7 @@ class CmdLineTest(unittest.TestCase):
stderr=subprocess.PIPE,
text=True)
err_msg = "Unknown option: --unknown-option\nusage: "
self.assertTrue(proc.stderr.startswith(err_msg), proc.stderr)
self.assertStartsWith(proc.stderr, err_msg)
self.assertNotEqual(proc.returncode, 0)
def test_int_max_str_digits(self):