Issue #15463: Write a test for faulthandler truncating the name of functions

to 500 characters.
This commit is contained in:
Victor Stinner 2012-08-01 19:45:34 +02:00
parent 98a387b65f
commit 53386d8f20

View File

@ -316,6 +316,30 @@ funcA()
with temporary_filename() as filename:
self.check_dump_traceback(filename)
def test_truncate(self):
maxlen = 500
func_name = 'x' * (maxlen + 50)
truncated = 'x' * maxlen + '...'
code = """
import faulthandler
def {func_name}():
faulthandler.dump_traceback(all_threads=False)
{func_name}()
""".strip()
code = code.format(
func_name=func_name,
)
expected = [
'Traceback (most recent call first):',
' File "<string>", line 4 in %s' % truncated,
' File "<string>", line 6 in <module>'
]
trace, exitcode = self.get_output(code)
self.assertEqual(trace, expected)
self.assertEqual(exitcode, 0)
@unittest.skipIf(not HAVE_THREADS, 'need threads')
def check_dump_traceback_threads(self, filename):
"""