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:

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
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:
try:
* * unittest.main()
except SystemExit:
* * pass
You most probably want this instead:

try:
unittest.main()
except SystemExit, exc:
# only exit if tests failed
if exc.code:
raise
Nov 19 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.