diff options
author | Martin Panter <vadmium+py@gmail.com> | 2016-09-22 09:37:39 (GMT) |
---|---|---|
committer | Martin Panter <vadmium+py@gmail.com> | 2016-09-22 09:37:39 (GMT) |
commit | bb8b1cb6af830b40f9be398d1e1bf8bdca772140 (patch) | |
tree | 87ca84797bced28ac715e49aacb6d4c07bbe264a /Lib/test/test_traceback.py | |
parent | 92bb90a9ff87fefd57a6e3274b21cc1b9ca16f53 (diff) | |
download | cpython-bb8b1cb6af830b40f9be398d1e1bf8bdca772140.zip cpython-bb8b1cb6af830b40f9be398d1e1bf8bdca772140.tar.gz cpython-bb8b1cb6af830b40f9be398d1e1bf8bdca772140.tar.bz2 |
Issue #27348: Restore “Exception: None” formatting in traceback module
This fixes a regression caused by revision 73afda5a4e4c. Also reverts the
decimal test workaround added in revision 5f3dd0a2b1ab.
Remove test_without_exception(). According to revision ecaafc32c500, this was
added in Python 2 so that print_exc() would output “None” when called with no
exception set. However print_exc() never worked like this in Python 3, and
the use case is not documented.
Restore TracebackCases class name (instead of SyntaxTracebackCases), because
the class also tests other exceptions.
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r-- | Lib/test/test_traceback.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 549d8d1..b4b74d3 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -19,7 +19,7 @@ test_frame = namedtuple('frame', ['f_code', 'f_globals', 'f_locals']) test_tb = namedtuple('tb', ['tb_frame', 'tb_lineno', 'tb_next']) -class SyntaxTracebackCases(unittest.TestCase): +class TracebackCases(unittest.TestCase): # For now, a very minimal set of tests. I want to be sure that # formatting of SyntaxErrors works based on changes for 2.1. @@ -106,10 +106,6 @@ class SyntaxTracebackCases(unittest.TestCase): str_name = '.'.join([X.__module__, X.__qualname__]) self.assertEqual(err[0], "%s: %s\n" % (str_name, str_value)) - def test_without_exception(self): - err = traceback.format_exception_only(None, None) - self.assertEqual(err, ['None\n']) - def test_encoded_file(self): # Test that tracebacks are correctly printed for encoded source files: # - correct line number (Issue2384) @@ -456,6 +452,17 @@ class BaseExceptionReportingTests: msg = self.get_report(e).splitlines() self.assertEqual(msg[-2], ' ^') + def test_message_none(self): + # A message that looks like "None" should not be treated specially + err = self.get_report(Exception(None)) + self.assertIn('Exception: None\n', err) + err = self.get_report(Exception('None')) + self.assertIn('Exception: None\n', err) + err = self.get_report(Exception()) + self.assertIn('Exception\n', err) + err = self.get_report(Exception('')) + self.assertIn('Exception\n', err) + class PyExcReportingTests(BaseExceptionReportingTests, unittest.TestCase): # |