Skip to content

Commit 4d438ec

Browse files
committed
fixup! fixup! fixup! fixup! fixup! fixup! fixup! Add tests for the fallback option
1 parent a65d281 commit 4d438ec

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Lib/test/test_sys.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ def test_excepthook_bytes_filename(self):
175175

176176
def test_excepthook(self):
177177
with test.support.captured_output("stderr") as stderr:
178-
sys.excepthook(1, '1', 1)
178+
with test.support.catch_unraisable_exception():
179+
sys.excepthook(1, '1', 1)
179180
self.assertTrue("TypeError: print_exception(): Exception expected for " \
180181
"value, str found" in stderr.getvalue())
181182

Lib/test/test_traceback.py

+3
Original file line numberDiff line numberDiff line change
@@ -1360,12 +1360,15 @@ class TestTracebackFormat(unittest.TestCase, TracebackFormatMixin):
13601360
class TestFallbackTracebackFormat(unittest.TestCase, TracebackFormatMixin):
13611361
DEBUG_RANGES = False
13621362
def setUp(self) -> None:
1363+
self.original_unraisable_hook = sys.unraisablehook
1364+
sys.unraisablehook = lambda *args: None
13631365
self.original_hook = traceback._print_exception_bltin
13641366
traceback._print_exception_bltin = lambda *args: 1/0
13651367
return super().setUp()
13661368

13671369
def tearDown(self) -> None:
13681370
traceback._print_exception_bltin = self.original_hook
1371+
sys.unraisablehook = self.original_unraisable_hook
13691372
return super().tearDown()
13701373

13711374
class BaseExceptionReportingTests:

0 commit comments

Comments
 (0)