diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2018-09-10 17:02:33 (GMT) |
---|---|---|
committer | Petr Viktorin <encukou@gmail.com> | 2018-09-10 17:02:33 (GMT) |
commit | 9797b7ae4496627836c55333765e10201a9840e3 (patch) | |
tree | dfe7d46da87ad6c308bb088ef6cc2a50c746c49e /Lib | |
parent | 0e0bc4e221f592f305d335faf5f8046484eb9238 (diff) | |
download | cpython-9797b7ae4496627836c55333765e10201a9840e3.zip cpython-9797b7ae4496627836c55333765e10201a9840e3.tar.gz cpython-9797b7ae4496627836c55333765e10201a9840e3.tar.bz2 |
bpo-26502: Implement FrameSummary.__len__() (GH-8632)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_traceback.py | 5 | ||||
-rw-r--r-- | Lib/traceback.py | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 8a3aa8a..3af85b8 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -868,6 +868,7 @@ class MiscTracebackCases(unittest.TestCase): (__file__, lineno+2, 'test_extract_stack', 'result = extract()'), (__file__, lineno+1, 'extract', 'return traceback.extract_stack()'), ]) + self.assertEqual(len(result[0]), 4) class TestFrame(unittest.TestCase): @@ -900,6 +901,10 @@ class TestFrame(unittest.TestCase): f = traceback.FrameSummary("f", 1, "dummy", line="line") self.assertEqual("line", f.line) + def test_len(self): + f = traceback.FrameSummary("f", 1, "dummy", line="line") + self.assertEqual(len(f), 4) + class TestStack(unittest.TestCase): diff --git a/Lib/traceback.py b/Lib/traceback.py index 4e7605d..ab35da9 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -279,6 +279,9 @@ class FrameSummary: return "<FrameSummary file {filename}, line {lineno} in {name}>".format( filename=self.filename, lineno=self.lineno, name=self.name) + def __len__(self): + return 4 + @property def line(self): if self._line is None: |