https://github.com/python/cpython/commit/048ee2d5ec761296ef67f5c59aee1f24408b12db
commit: 048ee2d5ec761296ef67f5c59aee1f24408b12db
branch: main
author: Irit Katriel <[email protected]>
committer: iritkatriel <[email protected]>
date: 2025-02-20T11:29:18Z
summary:
gh-130250: use support.swap_attr() in test and don't assume we're beginning
with a clean system state (#130342)
files:
M Lib/test/test_traceback.py
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 266a1ec04908fc..68c4fa117a90f5 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -511,14 +511,10 @@ def test_print_exception_exc(self):
self.assertEqual(output.getvalue(), "Exception: projector\n")
def test_print_last(self):
- self.assertIsNone(getattr(sys, "last_exc", None))
- try:
- sys.last_exc = ValueError(42)
+ with support.swap_attr(sys, 'last_exc', ValueError(42)):
output = StringIO()
traceback.print_last(file=output)
self.assertEqual(output.getvalue(), "ValueError: 42\n")
- finally:
- sys.last_exc = None
def test_format_exception_exc(self):
e = Exception("projector")
_______________________________________________
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]