]> granicus.if.org Git - python/commitdiff
Inspired by SF patch #860326, make the exception formatting by
authorGuido van Rossum <guido@python.org>
Sat, 26 Aug 2006 20:37:44 +0000 (20:37 +0000)
committerGuido van Rossum <guido@python.org>
Sat, 26 Aug 2006 20:37:44 +0000 (20:37 +0000)
traceback.py be closer to the built-in formatting.
A few unittests had to be fixed, too.

Lib/decimal.py
Lib/doctest.py
Lib/test/test_doctest.py
Lib/test/test_traceback.py
Lib/test/test_unpack.py
Lib/traceback.py

index a8fde82d4e8e1cd9567d419a035545d380ac78b9..99c0de6d3285011944b8c7ae3e4b96f81312bae0 100644 (file)
@@ -85,7 +85,7 @@ Traceback (most recent call last):
   ...
   ...
   ...
-DivisionByZero: x / 0
+decimal.DivisionByZero: x / 0
 >>> c = Context()
 >>> c.traps[InvalidOperation] = 0
 >>> print c.flags[InvalidOperation]
@@ -103,7 +103,7 @@ Traceback (most recent call last):
   ...
   ...
   ...
-InvalidOperation: 0 / 0
+decimal.InvalidOperation: 0 / 0
 >>> print c.flags[InvalidOperation]
 1
 >>> c.flags[InvalidOperation] = 0
index 2774ec16e7b8210abde1e5109732d8ddac95a538..71609075b4e94b79024c05638479d7917051e6ef 100644 (file)
@@ -1581,7 +1581,7 @@ class UnexpectedException(Exception):
 
     - test: the DocTest object being run
 
-    - excample: the Example object that failed
+    - example: the Example object that failed
 
     - exc_info: the exception info
     """
@@ -1664,7 +1664,7 @@ class DebugRunner(DocTestRunner):
          >>> runner.run(test)
          Traceback (most recent call last):
          ...
-         UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>
+         doctest.UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>
 
          >>> del test.globs['__builtins__']
          >>> test.globs
index 12d75dd2043dcee986a4188698b52b1467d8001b..1390e15b764633a922677009fbce398c2cfef1fd 100644 (file)
@@ -2234,7 +2234,7 @@ debugging):
     >>> doctest.testfile('test_doctest.txt', raise_on_error=True)
     ... # doctest: +ELLIPSIS
     Traceback (most recent call last):
-    UnexpectedException: ...
+    doctest.UnexpectedException: ...
     >>> doctest.master = None  # Reset master.
 
 If the tests contain non-ASCII characters, the tests might fail, since
index 6f9e46476ae0b5722e6c3340ed6fa0e5da34ffb1..9ba1dca23de83e4a0d1b322bbf8016ed6fa836dd 100644 (file)
@@ -118,7 +118,9 @@ def test():
         err = traceback.format_exception_only(X, X())
         self.assertEqual(len(err), 1)
         str_value = '<unprintable %s object>' % X.__name__
-        self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n')
+        self.assertEqual(err[0], "%s.%s: %s\n" % (X.__module__,
+                                                  X.__name__,
+                                                  str_value))
 
 
 def test_main():
index 3f726487e0a91bc6991ae579a80601f56f45639f..cd48689a11430aa5f0319a12d837218260d666c2 100644 (file)
@@ -107,7 +107,7 @@ error)
     >>> a, b, c, d, e = BadSeq()
     Traceback (most recent call last):
       ...
-    BozoError
+    test.test_unpack.BozoError
 
 Trigger code while expecting an IndexError (unpack sequence too short, wrong
 error)
@@ -115,7 +115,7 @@ error)
     >>> a, b, c = BadSeq()
     Traceback (most recent call last):
       ...
-    BozoError
+    test.test_unpack.BozoError
 
 """
 
index efd0f753943d9233d1158f59af76e9dd367e7053..eb2fdf690a24b37436ad7be7837d1104551b94fc 100644 (file)
@@ -163,6 +163,9 @@ def format_exception_only(etype, value):
     """
 
     stype = etype.__name__
+    smod = etype.__module__
+    if smod not in ("exceptions", "__main__", "__builtin__"):
+        stype = smod + '.' + stype
 
     if not issubclass(etype, SyntaxError):
         return [_format_final_exc_line(stype, value)]