[python] unittest in IDLE
最近開始抄別人的 code 來學習。在 IDLE 試著要用 unittest 做測試,結果發生以下問題:
----------------------------------------------------------------------
Ran 1 test in 0.054sOK
Traceback (most recent call last):
File "D:\test.py", line 150, in <module>
unittest.main()
File "C:\Python27\lib\unittest\main.py", line 95, in __init__
self.runTests()
File "C:\Python27\lib\unittest\main.py", line 231, in runTests
sys.exit(not self.result.wasSuccessful())
SystemExit: False
我找到網路上的解法,真的是可以用。
if __name__ == '__main__': unittest.main(exit=False)
參考:http://stackoverflow.com/questions/2457068/using-idle-to-run-python-pyunit-unit-tests