diff options
Diffstat (limited to 'Lib/test/test_cmd.py')
-rw-r--r-- | Lib/test/test_cmd.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py index 28f80766677..951336fa085 100644 --- a/Lib/test/test_cmd.py +++ b/Lib/test/test_cmd.py @@ -244,6 +244,21 @@ class TestAlternateInput(unittest.TestCase): "(Cmd) *** Unknown syntax: EOF\n")) +class CmdPrintExceptionClass(cmd.Cmd): + """ + GH-80731 + cmd.Cmd should print the correct exception in default() + >>> mycmd = CmdPrintExceptionClass() + >>> try: + ... raise ValueError("test") + ... except ValueError: + ... mycmd.onecmd("not important") + (<class 'ValueError'>, ValueError('test')) + """ + + def default(self, line): + print(sys.exc_info()[:2]) + def load_tests(loader, tests, pattern): tests.addTest(doctest.DocTestSuite()) return tests |