notests -h 无法运行并出现错误

发布于 2024-11-07 06:03:17 字数 950 浏览 3 评论 0原文

我怀疑我没有正确安装nosetests。 我使用了 easy_install 鼻子 - 输出是

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

所以它看起来安装得很好。但是当我运行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'

我是否错过了某个设置步骤?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尹雨沫 2024-11-14 06:03:17

诡异的。在 nose/core.py 中,TestProgram 构造函数调用父构造函数,如下所示:

...
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)

unittest/main.py< 中的 TestProgram 构造函数/code> 接受 exit 参数:

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):
        ...

所以...我不知道这个错误是如何发生的。您是否安装了更多版本的Python?您的鼻子测试是否真的使用了适用于 Python 2.7 的正确 unittest 模块?您可以查看 unittest\main.pyC:\Python27 中的某处)并检查 TestProgram 构造函数,它是否具有 <代码>退出参数?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文