mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (#130342)
This commit is contained in:
parent
417372bd43
commit
048ee2d5ec
1 changed files with 1 additions and 5 deletions
|
@ -511,14 +511,10 @@ class TracebackCases(unittest.TestCase):
|
|||
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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue