]> granicus.if.org Git - python/commitdiff
Issue #15463: Write a test for faulthandler truncating the name of functions
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 1 Aug 2012 17:45:34 +0000 (19:45 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 1 Aug 2012 17:45:34 +0000 (19:45 +0200)
to 500 characters.

Lib/test/test_faulthandler.py

index 8c12b213d00024ad6e0cc5abbf3b7360bfc1b4ad..c186b3472a4e19b5fb57909a34be2dc2a0995c21 100644 (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):
         """