Python: handle sys.exit in unit tests? -
i have management command can stuff, or can return sys.exit()
.
i'm trying handle second case follows in unit tests:
self.assertraises(systemexit) cm: call_command('geocode_practices', *args, **opts) self.assertequal(cm.exception, 1)
but gives me:
assertionerror: none != 1
what doing wrong?
also, what's best way handle different scenarios? @ moment test fail if script not exit.
apparently code inside with
block doesn't raise exception. note sys.exit()
raises systemexit
exception.
and if did, exception not compare equal 1. if not none
, cm.exception
attribute contains exception instance, not number.
Comments
Post a Comment