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.
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)
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):
#
def _format_final_exc_line(etype, value):
valuestr = _some_str(value)
- if value == 'None' or value is None or not valuestr:
+ if value is None or not valuestr:
line = "%s\n" % etype
else:
line = "%s: %s\n" % (etype, valuestr)