not causes:'升级'none-typetest'时出错

2024-04-26 14:06:03 发布

您现在位置:Python中文网/ 问答频道 /正文

升级pytest需要帮助。在3.2.4版本中,如果我移到3.3.x或3.4.x,就会出现一个我不理解的错误,甚至不能执行-h参数。不知道从哪里开始或者为什么会这样。也许我的virtualenv有问题吗?在

新鲜病毒

我确实尝试过从一个全新的virtualenv开始,但是,我仍然得到同样的错误。恢复到3.2.4修复了它。在

工作:

$ pytest --version
This is pytest version 3.2.4, imported from /Users/me/.virtualenvs/hitcount/lib/python3.5/site-packages/pytest.py

升级至3.3.x版本

^{pr2}$

资料来源:

这是我维护的一个开源项目:https://github.com/thornomad/django-hitcount


Tags: from版本参数virtualenvpytestisversion错误
1条回答
网友
1楼 · 发布于 2024-04-26 14:06:03

您遇到的是一个bug,它不在pytest中,而是在插件库中,它基于pluggy。这个错误在2个月前修复了(see this commit),但不幸的是,pluggy(0.6.0)的当前最新版本没有包含此修复。在

因此,您有两种可能性:

取决于pluggy快照

这是侵入性最小的一种。pytest不需要pluggy的严格版本,因此只需要开发版本,直到下一个pluggy版本:

# tests/requirements.txt

coverage==4.5.1
flake8==2.5.4
mock==2.0.0
pytest==3.4.2
pytest-django==3.1.2
selenium==3.10.0
tox==2.9.1
# add some meaningful explanation here 
# so you don't forget why you need this particular snapshot of pluggy
git+https://github.com/pytest-dev/pluggy@dcde058f93a509b9c39409fca02100e43bb43485

下一个版本发布后,请删除快照依赖项和凹凸:

^{pr2}$

适应pytest_configure钩子

调整pytest_configure钩子,使其不返回任何内容:

def configure():
    from django.conf import settings

    settings.configure(
        ...

    return settings

def pytest_configure():
    configure()

别忘了调用runtests.py中的configure()函数,而不是pytest_configure(),这样就可以开始了。但是,这只是一个临时的解决方案,一旦pluggy>0.6.0被释放,就可以恢复。在

相关问题 更多 >