MCPcopy
hub / github.com/django/django / test_system_exit

Method test_system_exit

tests/user_commands/tests.py:89–105  ·  view source on GitHub ↗

Exception raised in a command should raise CommandError with call_command, but SystemExit when run from command line

(self)

Source from the content-addressed store, hash-verified

87 management.call_command(("explode",))
88
89 def test_system_exit(self):
90 """Exception raised in a command should raise CommandError with
91 call_command, but SystemExit when run from command line
92 """
93 with self.assertRaises(CommandError) as cm:
94 management.call_command("dance", example="raise")
95 self.assertEqual(cm.exception.returncode, 3)
96 dance.Command.requires_system_checks = []
97 try:
98 with captured_stderr() as stderr, self.assertRaises(SystemExit) as cm:
99 management.ManagementUtility(
100 ["manage.py", "dance", "--example=raise"]
101 ).execute()
102 self.assertEqual(cm.exception.code, 3)
103 finally:
104 dance.Command.requires_system_checks = "__all__"
105 self.assertIn("CommandError", stderr.getvalue())
106
107 def test_no_translations_deactivate_translations(self):
108 """

Callers

nothing calls this directly

Calls 3

captured_stderrFunction · 0.90
executeMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected