[英]ImportError: cannot import name 'transfer_markers' when testing with pytest
When I run tests for my python project by running the following command: 当我通过运行以下命令为我的python项目运行测试时:
python setup.py test
(or)
pytest project_name
I get the following error: 我收到以下错误:
.../project_name/.eggs/pytest_asyncio-0.9.0-py3.6.egg/pytest_asyncio/plugin.py", line 8, in <module>
from _pytest.python import transfer_markers
ImportError: cannot import name 'transfer_markers'
When I looked it up online, there was almost no mention of that particular error message anywhere. 当我在网上查找时,几乎没有提到任何地方的特定错误消息。 Something similar has happened to me a few times before where previously working code just breaks and it's usually because there's a new version of an important package.
在之前工作的代码刚刚破解之前,我曾经发生过类似的事情,这通常是因为有一个重要软件包的新版本。
I looked at the pytest release history , and it looks like pytest==4.1.0
has been released a few hours ago (as of this post). 我查看了pytest发布历史 ,看起来
pytest==4.1.0
已经在几小时前发布了(截至本文)。
The solution is to revert back to the last stable version of pytest ie pytest==4.0.2
by running the following command: 解决方案是通过运行以下命令恢复到pytest的最后一个稳定版本即
pytest==4.0.2
:
pip install pytest==4.0.2
The tests are running now. 测试现在正在运行。
pytest-asyncio has been updated to 0.10.0 pytest-asyncio已更新至0.10.0
pytest-asyncio is using transfer_markers which is taken out in pytest 4.1.0. pytest-asyncio正在使用transfer_markers,它在pytest 4.1.0中被取出。 Looks like it's fixed and released.
看起来它已经修复并发布了。 Issue #105
问题#105
EDIT: You can now upgrade pip install pytest-asyncio==0.10.0
to fix this issue. 编辑:你现在可以升级
pip install pytest-asyncio==0.10.0
来解决这个问题。
Or update pytest-asyncio==0.10.0
in your requirements.txt 或者在requirements.txt中更新
pytest-asyncio==0.10.0
Don't forget to run pip uninstall pytest
to keep your pytest up-to-date if you previously installed pytest 4.0.2 to temporarily fix the issue 如果您之前安装了pytest 4.0.2以暂时解决问题,请不要忘记运行
pip uninstall pytest
以使pip uninstall pytest
保持最新状态
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.