diff options
| author | Jorge Bastida <me@jorgebastida.com> | 2013-05-18 18:04:45 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-05-20 18:59:37 +0200 |
| commit | 888c86dcf30defe533451bcefc6e09a6e181389f (patch) | |
| tree | d1e57aeb3bfe77f40b7f494f1ecdaa7e80ffe7db /tests/admin_scripts/tests.py | |
| parent | 4280217f31fc634d320b0cf30bcb6d582b19d784 (diff) | |
Fixed #20445 -- Raised original exception after command error
Diffstat (limited to 'tests/admin_scripts/tests.py')
| -rw-r--r-- | tests/admin_scripts/tests.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index c8986770f3..f0ef0fb293 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -1305,13 +1305,15 @@ class CommandTypes(AdminScriptTestCase): sys.stderr = err = StringIO() try: command.execute = lambda args: args # This will trigger TypeError - with self.assertRaises(SystemExit): + + # If the Exception is not CommandError it should always + # raise the original exception. + with self.assertRaises(TypeError): command.run_from_argv(['', '']) - err_message = err.getvalue() - # Exceptions other than CommandError automatically output the traceback - self.assertIn("Traceback", err_message) - self.assertIn("TypeError", err_message) + # If the Exception is CommandError and --traceback is not present + # this command should raise a SystemExit and don't print any + # traceback to the stderr. command.execute = raise_command_error err.truncate(0) with self.assertRaises(SystemExit): @@ -1320,12 +1322,12 @@ class CommandTypes(AdminScriptTestCase): self.assertNotIn("Traceback", err_message) self.assertIn("CommandError", err_message) + # If the Exception is CommandError and --traceback is present + # this command should raise the original CommandError as if it + # were not a CommandError. err.truncate(0) - with self.assertRaises(SystemExit): + with self.assertRaises(CommandError): command.run_from_argv(['', '', '--traceback']) - err_message = err.getvalue() - self.assertIn("Traceback (most recent call last)", err_message) - self.assertIn("CommandError", err_message) finally: sys.stderr = old_stderr |
