https://github.com/python/cpython/commit/4b37a6bda236121c130b4a60e573f123cb5e4c58
commit: 4b37a6bda236121c130b4a60e573f123cb5e4c58
branch: main
author: Serhiy Storchaka <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2025-01-21T16:45:20+02:00
summary:
gh-71339: Fix an order-dependent failure in test_unittest (GH-129133)
It failed if it was preceded by test_builtin.
files:
M Lib/test/test_builtin.py
M Lib/test/test_unittest/test_case.py
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 73b139e405ae59..913d007a126d72 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1833,7 +1833,10 @@ def test_bug_27936(self):
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')
diff --git a/Lib/test/test_unittest/test_case.py
b/Lib/test/test_unittest/test_case.py
index df1381451b7ebc..a04af55f3fc0ae 100644
--- a/Lib/test/test_unittest/test_case.py
+++ b/Lib/test/test_unittest/test_case.py
@@ -801,9 +801,9 @@ def testAssertHasAttr(self):
self.assertEqual(str(cm.exception),
"type object 'List' has no attribute 'spam'")
with self.assertRaises(self.failureException) as cm:
- self.assertHasAttr(sys, 'spam')
+ self.assertHasAttr(sys, 'nonexistent')
self.assertEqual(str(cm.exception),
- "module 'sys' has no attribute 'spam'")
+ "module 'sys' has no attribute 'nonexistent'")
with self.assertRaises(self.failureException) as cm:
self.assertHasAttr(a, 'y', 'ababahalamaha')
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]