I have a management command that can do stuff, or can return a sys.exit().
I'm trying to handle the second case as follows in my unit tests:
with self.assertRaises(SystemExit) as cm:
call_command('geocode_practices', *args, **opts)
self.assertEqual(cm.exception, 1)
But this gives me:
AssertionError: None != 1
What am I doing wrong?
Also, what's the best way to handle the different scenarios? At the moment my test will fail if the script does not exit.
sys.exit()case? And should this command be callingsys.exit()at all?SystemExitis really a bad idea.