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

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -