[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

@ -539,9 +539,9 @@ class BasicSocketTests(unittest.TestCase):
openssl_ver = f"OpenSSL {major:d}.{minor:d}.{patch:d}"
else:
openssl_ver = f"OpenSSL {major:d}.{minor:d}.{fix:d}"
self.assertTrue(
s.startswith((openssl_ver, libressl_ver, "AWS-LC")),
(s, t, hex(n))
self.assertStartsWith(
s, (openssl_ver, libressl_ver, "AWS-LC"),
(t, hex(n))
)
@support.cpython_only
@ -1668,7 +1668,7 @@ class SSLErrorTests(unittest.TestCase):
regex = "(NO_START_LINE|UNSUPPORTED_PUBLIC_KEY_TYPE)"
self.assertRegex(cm.exception.reason, regex)
s = str(cm.exception)
self.assertTrue("NO_START_LINE" in s, s)
self.assertIn("NO_START_LINE", s)
def test_subclass(self):
# Check that the appropriate SSLError subclass is raised
@ -1683,7 +1683,7 @@ class SSLErrorTests(unittest.TestCase):
with self.assertRaises(ssl.SSLWantReadError) as cm:
c.do_handshake()
s = str(cm.exception)
self.assertTrue(s.startswith("The operation did not complete (read)"), s)
self.assertStartsWith(s, "The operation did not complete (read)")
# For compatibility
self.assertEqual(cm.exception.errno, ssl.SSL_ERROR_WANT_READ)