Re: [Tutor] Unittest traceback

2008-04-04 Thread Kent Johnson
Oleg Oltar wrote:
> Hi! 
> 
> I am trying to use unittest in python first time. But have a strange 
> traceback each time I run my sample tests.

How are you running the test? My guess is that you are running it in an 
IDE or something that shows the normal system exit exception.

Calling sys.exit() raises the SystemExit exception with a result code. 
Normally this is not shown by the runner.

In Python False == 0 so your program is exiting normally with a code of 
0 (no error). It is probably the program runner that is showing the 
traceback.

Try running the program from the command line.

Kent

> Can you please explain why I have it. No info about it in the doc. 
> e.g. the code is
> 
> import unittest
> import squaren
> 
> class TestCases(unittest.TestCase):
> def setUp(self):
> pass
> 
> def testsmall(self):
> self.assertEqual(True, True)
> 
> 
> 
> if __name__ == '__main__':
> unittest.main()
> 
> And the traceback is 
> 
> --
> Ran 1 test in 0.000s
> 
> OK
> Traceback (most recent call last):
>   File "/tmp/py359hJx", line 14, in 
> unittest.main()
>   File "/opt/local/lib/python2.5/unittest.py", line 768, in __init__
> self.runTests()
>   File "/opt/local/lib/python2.5/unittest.py", line 806, in runTests
> sys.exit(not result.wasSuccessful())
> SystemExit: False
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Unittest traceback

2008-04-04 Thread Oleg Oltar
Hi!
I am trying to use unittest in python first time. But have a strange
traceback each time I run my sample tests.
Can you please explain why I have it. No info about it in the doc.
e.g. the code is

import unittest
import squaren

class TestCases(unittest.TestCase):
def setUp(self):
pass

def testsmall(self):
self.assertEqual(True, True)



if __name__ == '__main__':
unittest.main()

And the traceback is

--
Ran 1 test in 0.000s

OK
Traceback (most recent call last):
  File "/tmp/py359hJx", line 14, in 
unittest.main()
  File "/opt/local/lib/python2.5/unittest.py", line 768, in __init__
self.runTests()
  File "/opt/local/lib/python2.5/unittest.py", line 806, in runTests
sys.exit(not result.wasSuccessful())
SystemExit: False
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor