Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
392 views
in Technique[技术] by (71.8m points)

python - Unittest causing sys.exit()

No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on.

IDLE 1.2.2      ==== No Subprocess ====
>>> import unittest
>>> 
>>> class Test(unittest.TestCase):
        def testA(self):
            a = 1
            self.assertEqual(a,1)

>>> unittest.main()
option -n not recognized
Usage: idle.pyw [options] [test] [...]

Options:
  -h, --help       Show this message
  -v, --verbose    Verbose output
  -q, --quiet      Minimal output

 Examples:
   idle.pyw                               - run default set of tests
   idle.pyw MyTestSuite                   - run suite 'MyTestSuite'
   idle.pyw MyTestCase.testSomething      - run MyTestCase.testSomething
   idle.pyw MyTestCase                    - run all 'test*' test methods
                                           in MyTestCase

Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    unittest.main()
  File "E:Python25libunittest.py", line 767, in __init__
    self.parseArgs(argv)
  File "E:Python25libunittest.py", line 796, in parseArgs
    self.usageExit(msg)
  File "E:Python25libunittest.py", line 773, in usageExit
    sys.exit(2)
SystemExit: 2
>>> 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In new Python 2.7 release, unittest.main() has a new argument.

If 'exit' is set to False, sys.exit() is not called during the execution of unittest.main().


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...