Issue #23883: Add missing entries to traceback.__all__.

This commit is contained in:
Berker Peksag 2015-04-08 09:47:14 +03:00
parent cb6fdf2c63
commit 716b3d3e91
2 changed files with 19 additions and 9 deletions

View File

@ -6,8 +6,7 @@ import linecache
import sys import sys
import unittest import unittest
import re import re
from test.support import run_unittest, Error, captured_output from test.support import TESTFN, Error, captured_output, unlink, cpython_only
from test.support import TESTFN, unlink, cpython_only
from test.script_helper import assert_python_ok from test.script_helper import assert_python_ok
import textwrap import textwrap
@ -593,7 +592,7 @@ class TestStack(unittest.TestCase):
traceback.walk_stack(None), capture_locals=True, limit=1) traceback.walk_stack(None), capture_locals=True, limit=1)
s = some_inner(3, 4) s = some_inner(3, 4)
self.assertEqual( self.assertEqual(
[' File "' + __file__ + '", line 593, ' [' File "' + __file__ + '", line 592, '
'in some_inner\n' 'in some_inner\n'
' traceback.walk_stack(None), capture_locals=True, limit=1)\n' ' traceback.walk_stack(None), capture_locals=True, limit=1)\n'
' a = 1\n' ' a = 1\n'
@ -603,7 +602,6 @@ class TestStack(unittest.TestCase):
], s.format()) ], s.format())
class TestTracebackException(unittest.TestCase): class TestTracebackException(unittest.TestCase):
def test_smoke(self): def test_smoke(self):
@ -732,8 +730,19 @@ class TestTracebackException(unittest.TestCase):
self.assertEqual(exc.stack[0].locals, None) self.assertEqual(exc.stack[0].locals, None)
def test_main(): class MiscTest(unittest.TestCase):
run_unittest(__name__)
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__": if __name__ == "__main__":
test_main() unittest.main()

View File

@ -7,8 +7,9 @@ import operator
__all__ = ['extract_stack', 'extract_tb', 'format_exception', __all__ = ['extract_stack', 'extract_tb', 'format_exception',
'format_exception_only', 'format_list', 'format_stack', 'format_exception_only', 'format_list', 'format_stack',
'format_tb', 'print_exc', 'format_exc', 'print_exception', 'format_tb', 'print_exc', 'format_exc', 'print_exception',
'print_last', 'print_stack', 'print_tb', 'print_last', 'print_stack', 'print_tb', 'clear_frames',
'clear_frames'] 'FrameSummary', 'StackSummary', 'TracebackException',
'walk_stack', 'walk_tb']
# #
# Formatting and printing lists of traceback lines. # Formatting and printing lists of traceback lines.