unittest exits

Chris Rebert clp at rebertia.com
Thu Nov 13 14:20:27 EST 2008


On Thu, Nov 13, 2008 at 11:01 AM, Alan Baljeu <alanbaljeu at yahoo.com> wrote:
> When I call unittest.main(), it invokes sys.exit().  I would like to run tests without exiting.  How can I?

There's probably a better way that stops it from trying to exit in the
first place, but here's a quick kludge:

try:
    unittest.main()
except SystemExit:
    pass

sys.exit() does its job by noting the return code and then raising the
SystemExit exception, which you are free to catch.

Cheers,
Chris
-- 
Follow the path of the Iguana...
http://rebertia.com

>
>
>  Alan Baljeu
>
>
>      __________________________________________________________________
> Instant Messaging, free SMS, sharing photos and more... Try the new Yahoo! Canada Messenger at http://ca.beta.messenger.yahoo.com/
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list