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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -