Skip to content

gh-71339: Fix an order-dependent failure in test_unittest #129133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Lib/test/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_unittest/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Loading