bpo-46299: improve test_descr.py with stricter error handling (GH-30471)

(cherry picked from commit e63066cfed)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2022-01-07 21:26:01 -08:00 committed by GitHub
parent bea3f42bb7
commit d2245cf190
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2545,10 +2545,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.
@ -4062,7 +4060,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):
@ -4448,6 +4446,8 @@ order (MRO) for bases """
print("Oops!")
except RuntimeError:
pass
else:
self.fail("Didn't raise RuntimeError")
finally:
sys.stdout = test_stdout