summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
authorAmmar Askar <ammar@ammaraskar.com>2021-07-16 12:21:16 (GMT)
committerGitHub <noreply@github.com>2021-07-16 12:21:16 (GMT)
commit8ce3008585feed51bd08ec256a19923940d744d4 (patch)
treeea35281e31dbf3b9a8c14772cc920a1b941dc310 /Lib/test/test_traceback.py
parenta283ef116ba909f133a8e16bb8d17d9e613831d8 (diff)
downloadcpython-8ce3008585feed51bd08ec256a19923940d744d4.zip
cpython-8ce3008585feed51bd08ec256a19923940d744d4.tar.gz
cpython-8ce3008585feed51bd08ec256a19923940d744d4.tar.bz2
bpo-44569: Decouple frame formatting in traceback.py (GH-27038)
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 402f773..4742eb1 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -1429,6 +1429,21 @@ class TestStack(unittest.TestCase):
' v = 4\n' % (__file__, some_inner.__code__.co_firstlineno + 3)
], s.format())
+ def test_custom_format_frame(self):
+ class CustomStackSummary(traceback.StackSummary):
+ def format_frame(self, frame):
+ return f'{frame.filename}:{frame.lineno}'
+
+ def some_inner():
+ return CustomStackSummary.extract(
+ traceback.walk_stack(None), limit=1)
+
+ s = some_inner()
+ self.assertEqual(
+ s.format(),
+ [f'{__file__}:{some_inner.__code__.co_firstlineno + 1}'])
+
+
class TestTracebackException(unittest.TestCase):
def test_smoke(self):