By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,931 Members | 1,976 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,931 IT Pros & Developers. It's quick & easy.

Re: unittest exits

P: n/a
On Thu, Nov 13, 2008 at 11:01 AM, Alan Baljeu <al********@yahoo.comwrote:
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:

except SystemExit:

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

Follow the path of the Iguana...

Alan Baljeu
__________________________________________________ ________________
Instant Messaging, free SMS, sharing photos and more... Try the new Yahoo! Canada Messenger at
Nov 13 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a
On 13 Nov., 20:20, "Chris Rebert" <c...@rebertia.comwrote:
* * unittest.main()
except SystemExit:
* * pass
You most probably want this instead:

except SystemExit, exc:
# only exit if tests failed
if exc.code:
Nov 19 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.