diff options
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 |
