summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-08-01 17:45:34 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-08-01 17:45:34 (GMT)
commit53386d8f206453317110cb0f80d2147eab34c916 (patch)
tree3bb08648a284a9e9291e71a16576d7f63ae1163c
parent98a387b65f6a9ce36654047704013f3bc4fe9916 (diff)
downloadcpython-53386d8f206453317110cb0f80d2147eab34c916.zip
cpython-53386d8f206453317110cb0f80d2147eab34c916.tar.gz
cpython-53386d8f206453317110cb0f80d2147eab34c916.tar.bz2
Issue #15463: Write a test for faulthandler truncating the name of functions
to 500 characters.
-rw-r--r--Lib/test/test_faulthandler.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index 8c12b21..c186b34 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -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):
"""