summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2021-09-03 07:30:17 (GMT)
committerGitHub <noreply@github.com>2021-09-03 07:30:17 (GMT)
commitb4b6342848ec0459182a992151099252434cc619 (patch)
tree049ee796fb01dee4844bccc61fb7427eb169ccf4 /Lib/test/test_traceback.py
parenta1e15a7a604e6f44cdaf4e106339df62eac5dc9f (diff)
downloadcpython-b4b6342848ec0459182a992151099252434cc619.zip
cpython-b4b6342848ec0459182a992151099252434cc619.tar.gz
cpython-b4b6342848ec0459182a992151099252434cc619.tar.bz2
bpo-45083: Include the exception class qualname when formatting an exception (GH-28119)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index d1967aa..ee2896c 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -1171,6 +1171,19 @@ class BaseExceptionReportingTests:
exp = "\n".join(expected)
self.assertEqual(exp, err)
+ def test_format_exception_only_qualname(self):
+ class A:
+ class B:
+ class X(Exception):
+ def __str__(self):
+ return "I am X"
+ pass
+ err = self.get_report(A.B.X())
+ str_value = 'I am X'
+ str_name = '.'.join([A.B.X.__module__, A.B.X.__qualname__])
+ exp = "%s: %s\n" % (str_name, str_value)
+ self.assertEqual(exp, err)
+
class PyExcReportingTests(BaseExceptionReportingTests, unittest.TestCase):
#