Re: [Pyunit-interest] Newbie question
Brought to you by:
purcell
From: Steve P. <ste...@ya...> - 2004-09-09 08:17:41
|
Hi Jim, unittest.main() is designed to turn a test module into an executable test script, it explicitly calls 'sys.exit()' to indicate success or otherwise. You are running the entire script from within the interpreter, and the interpreter is reporting to you that sys.exit() has been called, which works by raising SystemExit. In other words, it's nothing to worry about, but it is a nuisance when pushing an entire test script through the interpreter, as happens when executing a script in emacs' python mode. One way to avoid having the traceback printed out is to replace unittest.main() with try: unittest.main() except SystemExit: pass Best wishes, -Steve -- http://www.pythonconsulting.com/ On Wednesday 08 September 2004 19:42, Frohnhofer, James wrote: > Is it expected behavior that the text-based test runner print a stack > traceback upon completion? For example (from the pyunit documentation): > > import unittest > > class IntegerArithmenticTestCase(unittest.TestCase): > def testAdd(self): ## test method names begin 'test*' > self.assertEquals((1 + 2), 3) > self.assertEquals(0 + 1, 1) > def testMultiply(self): > self.assertEquals((0 * 10), 0) > self.assertEquals((5 * 8), 40) > > if __name__ == '__main__': > unittest.main() > > > When run as a script returns: > > > .. > ---------------------------------------------------------------------- > Ran 2 tests in 0.015s > > OK > Traceback (most recent call last): > File "H:/Python23/Lib/testest.py", line 12, in ? > unittest.main() > File "H:\Python23\lib\unittest.py", line 721, in __init__ > self.runTests() > File "H:\Python23\lib\unittest.py", line 759, in runTests > sys.exit(not result.wasSuccessful()) > SystemExit: False > > > > While I can see the OK and the two dots (..) for success, I would expect > success not to be followed by a stack trace. Am I doing something wrong > or am I being a moron -- a real possibility. I am familiar with xUnit, > but fairly new to Python. > > Thanks, > > Jim > > ========================================================================= >===== This message is for the sole use of the intended recipient. If you > received this message in error please delete it and notify us. If this > message was misdirected, CSFB does not waive any confidentiality or > privilege. CSFB retains and monitors electronic communications sent > through its network. Instructions transmitted over this system are not > binding on CSFB until they are confirmed by us. Message transmission is > not guaranteed to be secure. > ========================================================================= >===== > > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click > _______________________________________________ > Pyunit-interest mailing list > Pyu...@li... > https://lists.sourceforge.net/lists/listinfo/pyunit-interest |