https://github.com/python/cpython/commit/96a914ad7e95d21799bbd8bf275d593eaf5e92ba commit: 96a914ad7e95d21799bbd8bf275d593eaf5e92ba branch: 3.12 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: iritkatriel <1055913+iritkatr...@users.noreply.github.com> date: 2025-02-20T11:45:42Z summary:
[3.12] gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (GH-130342) (#130345) gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (GH-130342) (cherry picked from commit 048ee2d5ec761296ef67f5c59aee1f24408b12db) Co-authored-by: Irit Katriel <1055913+iritkatr...@users.noreply.github.com> files: M Lib/test/test_traceback.py diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 0b8462dfd5265f..8300e511cf4232 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -329,14 +329,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 -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com