gh-71339: Use new assertion methods in tests (GH-129046)

This commit is contained in:
Serhiy Storchaka 2025-05-22 13:17:22 +03:00 committed by GitHub
parent bb244fd33d
commit 2602d8ae98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
117 changed files with 407 additions and 445 deletions

View file

@ -553,9 +553,9 @@ class CmdLineTest(unittest.TestCase):
exitcode, stdout, stderr = assert_python_failure(script_name)
text = stderr.decode('ascii').split('\n')
self.assertEqual(len(text), 5)
self.assertTrue(text[0].startswith('Traceback'))
self.assertTrue(text[1].startswith(' File '))
self.assertTrue(text[3].startswith('NameError'))
self.assertStartsWith(text[0], 'Traceback')
self.assertStartsWith(text[1], ' File ')
self.assertStartsWith(text[3], 'NameError')
def test_non_ascii(self):
# Apple platforms deny the creation of a file with an invalid UTF-8 name.
@ -708,9 +708,8 @@ class CmdLineTest(unittest.TestCase):
exitcode, stdout, stderr = assert_python_failure(script_name)
text = io.TextIOWrapper(io.BytesIO(stderr), 'ascii').read()
# It used to crash in https://github.com/python/cpython/issues/111132
self.assertTrue(text.endswith(
'SyntaxError: nonlocal declaration not allowed at module level\n',
), text)
self.assertEndsWith(text,
'SyntaxError: nonlocal declaration not allowed at module level\n')
def test_consistent_sys_path_for_direct_execution(self):
# This test case ensures that the following all give the same