MCPcopy Index your code
hub / github.com/python/cpython / test_excepthook_bytes_filename

Method test_excepthook_bytes_filename

Lib/test/test_sys.py:179–194  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

177
178 @force_not_colorized
179 def test_excepthook_bytes_filename(self):
180 # bpo-37467: sys.excepthook() must not crash if a filename
181 # is a bytes string
182 with warnings.catch_warnings():
183 warnings.simplefilter('ignore', BytesWarning)
184
185 try:
186 raise SyntaxError("msg", (b"bytes_filename", 123, 0, "text"))
187 except SyntaxError as exc:
188 with support.captured_stderr() as err:
189 sys.__excepthook__(*sys.exc_info())
190
191 err = err.getvalue()
192 self.assertIn(""" File "b'bytes_filename'", line 123\n""", err)
193 self.assertIn(""" text\n""", err)
194 self.assertEndsWith(err, "SyntaxError: msg\n")
195
196 def test_excepthook(self):
197 with test.support.captured_output("stderr") as stderr:

Callers

nothing calls this directly

Calls 3

assertInMethod · 0.80
assertEndsWithMethod · 0.80
getvalueMethod · 0.45

Tested by

no test coverage detected