mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-71339: Fix an order-dependent failure in test_unittest (GH-129133)
It failed if it was preceded by test_builtin.
This commit is contained in:
parent
5809b25909
commit
4b37a6bda2
2 changed files with 6 additions and 3 deletions
|
@ -1833,7 +1833,10 @@ class BuiltinTest(ComplexesAreIdenticalMixin, unittest.TestCase):
|
||||||
|
|
||||||
def test_setattr(self):
|
def test_setattr(self):
|
||||||
setattr(sys, 'spam', 1)
|
setattr(sys, 'spam', 1)
|
||||||
|
try:
|
||||||
self.assertEqual(sys.spam, 1)
|
self.assertEqual(sys.spam, 1)
|
||||||
|
finally:
|
||||||
|
del sys.spam
|
||||||
self.assertRaises(TypeError, setattr)
|
self.assertRaises(TypeError, setattr)
|
||||||
self.assertRaises(TypeError, setattr, sys)
|
self.assertRaises(TypeError, setattr, sys)
|
||||||
self.assertRaises(TypeError, setattr, sys, 'spam')
|
self.assertRaises(TypeError, setattr, sys, 'spam')
|
||||||
|
|
|
@ -801,9 +801,9 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
||||||
self.assertEqual(str(cm.exception),
|
self.assertEqual(str(cm.exception),
|
||||||
"type object 'List' has no attribute 'spam'")
|
"type object 'List' has no attribute 'spam'")
|
||||||
with self.assertRaises(self.failureException) as cm:
|
with self.assertRaises(self.failureException) as cm:
|
||||||
self.assertHasAttr(sys, 'spam')
|
self.assertHasAttr(sys, 'nonexistent')
|
||||||
self.assertEqual(str(cm.exception),
|
self.assertEqual(str(cm.exception),
|
||||||
"module 'sys' has no attribute 'spam'")
|
"module 'sys' has no attribute 'nonexistent'")
|
||||||
|
|
||||||
with self.assertRaises(self.failureException) as cm:
|
with self.assertRaises(self.failureException) as cm:
|
||||||
self.assertHasAttr(a, 'y', 'ababahalamaha')
|
self.assertHasAttr(a, 'y', 'ababahalamaha')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue