简体   繁体   中英

nosetests -h fails to run with error

I suspect I failed to install nosetests correctly. I used easy_install nose - output was

Searching for nose
Best match: nose 1.0.0
Processing nose-1.0.0-py2.7.egg
nose 1.0.0 is already the active version in easy-install.pth
Installing nosetests-script.py script to C:\Python27\Scripts
Installing nosetests.exe script to C:\Python27\Scripts
Installing nosetests-2.7-script.py script to C:\Python27\Script
Installing nosetests-2.7.exe script to C:\Python27\Scripts

So it looks like it installs fine. But when I run nosetests -h

PS C:\Users\john\code\python> nosetests -h
Traceback (most recent call last):
  File "C:\Python27\Scripts\nosetests-script.py", line 9, in <module>
    load_entry_point('nose==1.0.0', 'console_scripts', 'nosetests')()
  File "C:\Python27\lib\site-packages\nose-1.0.0-py2.7.egg\nose\core.py", line 118, in __init__
    **extra_args)
TypeError: __init__() got an unexpected keyword argument 'exit'

Did I miss a setup step somehow?

Weird. In nose/core.py the TestProgram constructor calls the parent constructor like this:

...
extra_args = {}
version = sys.version_info[0:2]
if version >= (2,7) and version != (3,0):
    extra_args['exit'] = exit
unittest.TestProgram.__init__(
    self, module=module, defaultTest=defaultTest,
    argv=argv, testRunner=testRunner, testLoader=testLoader,
    **extra_args)

Constructor of TestProgram in unittest/main.py accepts the exit argument:

class TestProgram(object):
    ...
    def __init__(self, module='__main__', defaultTest=None, argv=None,
                    testRunner=None, testLoader=loader.defaultTestLoader,
                    exit=True, verbosity=1, failfast=None, catchbreak=None,
                    buffer=None):
        ...

So... I don't know how this error could happen. Do you have more versions of Python installed? Is your nosetests really using the correct unittest module for Python 2.7? Can you look at unittest\\main.py (somewhere in your C:\\Python27 ) and check the TestProgram constructor, whether it has an exit argument?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM