[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

@ -10,13 +10,11 @@ class ExceptionClassTests(unittest.TestCase):
inheritance hierarchy)"""
def test_builtins_new_style(self):
self.assertTrue(issubclass(Exception, object))
self.assertIsSubclass(Exception, object)
def verify_instance_interface(self, ins):
for attr in ("args", "__str__", "__repr__"):
self.assertTrue(hasattr(ins, attr),
"%s missing %s attribute" %
(ins.__class__.__name__, attr))
self.assertHasAttr(ins, attr)
def test_inheritance(self):
# Make sure the inheritance hierarchy matches the documentation
@ -65,7 +63,7 @@ class ExceptionClassTests(unittest.TestCase):
elif last_depth > depth:
while superclasses[-1][0] >= depth:
superclasses.pop()
self.assertTrue(issubclass(exc, superclasses[-1][1]),
self.assertIsSubclass(exc, superclasses[-1][1],
"%s is not a subclass of %s" % (exc.__name__,
superclasses[-1][1].__name__))
try: # Some exceptions require arguments; just skip them