From 716b3d3e9137aeeed4ee3480a5302c54442405b6 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Wed, 8 Apr 2015 09:47:14 +0300 Subject: Issue #23883: Add missing entries to traceback.__all__. --- Lib/test/test_traceback.py | 23 ++++++++++++++++------- Lib/traceback.py | 5 +++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 9c8929f..2fa85f5 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -6,8 +6,7 @@ import linecache import sys import unittest import re -from test.support import run_unittest, Error, captured_output -from test.support import TESTFN, unlink, cpython_only +from test.support import TESTFN, Error, captured_output, unlink, cpython_only from test.script_helper import assert_python_ok import textwrap @@ -593,7 +592,7 @@ class TestStack(unittest.TestCase): traceback.walk_stack(None), capture_locals=True, limit=1) s = some_inner(3, 4) self.assertEqual( - [' File "' + __file__ + '", line 593, ' + [' File "' + __file__ + '", line 592, ' 'in some_inner\n' ' traceback.walk_stack(None), capture_locals=True, limit=1)\n' ' a = 1\n' @@ -603,7 +602,6 @@ class TestStack(unittest.TestCase): ], s.format()) - class TestTracebackException(unittest.TestCase): def test_smoke(self): @@ -732,8 +730,19 @@ class TestTracebackException(unittest.TestCase): self.assertEqual(exc.stack[0].locals, None) -def test_main(): - run_unittest(__name__) +class MiscTest(unittest.TestCase): + + def test_all(self): + expected = set() + blacklist = {'print_list'} + for name in dir(traceback): + if name.startswith('_') or name in blacklist: + continue + module_object = getattr(traceback, name) + if getattr(module_object, '__module__', None) == 'traceback': + expected.add(name) + self.assertCountEqual(traceback.__all__, expected) + if __name__ == "__main__": - test_main() + unittest.main() diff --git a/Lib/traceback.py b/Lib/traceback.py index f7705cd..8a554cf 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -7,8 +7,9 @@ import operator __all__ = ['extract_stack', 'extract_tb', 'format_exception', 'format_exception_only', 'format_list', 'format_stack', 'format_tb', 'print_exc', 'format_exc', 'print_exception', - 'print_last', 'print_stack', 'print_tb', - 'clear_frames'] + 'print_last', 'print_stack', 'print_tb', 'clear_frames', + 'FrameSummary', 'StackSummary', 'TracebackException', + 'walk_stack', 'walk_tb'] # # Formatting and printing lists of traceback lines. -- cgit v0.12