]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46299: improve `test_descr.py` with stricter error handling (GH-30471)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 8 Jan 2022 05:26:11 +0000 (21:26 -0800)
committerGitHub <noreply@github.com>
Sat, 8 Jan 2022 05:26:11 +0000 (21:26 -0800)
(cherry picked from commit e63066cfed27511c9b786d61761f87f7a532571a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_descr.py

index 0e6a784c6c14babb5443bd873d6a54084cc22452..e5e9f4939699ee0580aff9c40afcf97ae0e76d67 100644 (file)
@@ -2531,10 +2531,8 @@ order (MRO) for bases """
         m2instance.b = 2
         m2instance.a = 1
         self.assertEqual(m2instance.__dict__, "Not a dict!")
-        try:
+        with self.assertRaises(TypeError):
             dir(m2instance)
-        except TypeError:
-            pass
 
         # Two essentially featureless objects, (Ellipsis just inherits stuff
         # from object.
@@ -4013,7 +4011,7 @@ order (MRO) for bases """
         except TypeError:
             pass
         else:
-            assert 0, "best_base calculation found wanting"
+            self.fail("best_base calculation found wanting")
 
     def test_unsubclassable_types(self):
         with self.assertRaises(TypeError):
@@ -4399,6 +4397,8 @@ order (MRO) for bases """
             print("Oops!")
         except RuntimeError:
             pass
+        else:
+            self.fail("Didn't raise RuntimeError")
         finally:
             sys.stdout = test_stdout