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:
Serhiy Storchaka 2025-01-21 16:45:20 +02:00 committed by GitHub
parent 5809b25909
commit 4b37a6bda2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -1833,7 +1833,10 @@ class BuiltinTest(ComplexesAreIdenticalMixin, unittest.TestCase):
def test_setattr(self):
setattr(sys, 'spam', 1)
self.assertEqual(sys.spam, 1)
try:
self.assertEqual(sys.spam, 1)
finally:
del sys.spam
self.assertRaises(TypeError, setattr)
self.assertRaises(TypeError, setattr, sys)
self.assertRaises(TypeError, setattr, sys, 'spam')