summaryrefslogtreecommitdiff
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-04-12 21:14:09 +0000
committerGeorg Brandl <georg@python.org>2006-04-12 21:14:09 +0000
commit24c274f5dc2f2f9ebe6d3c9ee087b80d40bd49b4 (patch)
tree6d2142f4321d52c38345cc5f32876fa91ac0ea97 /Lib/test/test_traceback.py
parent64029986bc8b7c7eac7bc6f6265d3d3163d8bb06 (diff)
downloadcpython-git-24c274f5dc2f2f9ebe6d3c9ee087b80d40bd49b4.tar.gz
Patch #860326: traceback.format_exception_only() now prepends the
exception's module name to non-builtin exceptions, like the interpreter itself does.
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 22c04567a7..26ab7dc111 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -5,6 +5,9 @@ from test.test_support import run_unittest, is_jython
import traceback
+class TbError(Exception):
+ pass
+
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.
@@ -103,6 +106,24 @@ def test():
import sys
sys.exc_traceback.__members__
+ def raise_tberror(self):
+ raise TbError
+
+ def raise_typeerror(self):
+ raise TypeError
+
+ def test_modulename(self):
+ # Bug 860326: format_exception_only should prepend module name
+ # to exceptions not in "exceptions", like PyErr_Print does.
+ err = self.get_exception_format(self.raise_tberror, TbError)
+ self.assertEquals(len(err), 1)
+ self.assert_(err[0] == '__main__.TbError\n' or
+ err[0] == 'test.test_traceback.TbError\n')
+
+ err = self.get_exception_format(self.raise_typeerror, TypeError)
+ self.assertEquals(err[0], 'TypeError\n')
+
+
def test_main():
run_unittest(TracebackCases)