pytest升级到4.0.2后如何正确替换@pytest.mark.gen_test?
How to properly replace @pytest.mark.gen_test after pytest upgrade to 4.0.2?
我有在 pytest 3.8.2 下通过的龙卷风协程测试,但最近我升级到 4.0.2,现在我得到这些测试失败并显示以下消息。
@pytest.mark.tryfirst
def pytest_pyfunc_call(pyfuncitem):
gen_test_mark = pyfuncitem.keywords.get('gen_test')
if gen_test_mark:
io_loop = pyfuncitem.funcargs.get('io_loop')
> run_sync = gen_test_mark.kwargs.get('run_sync', True)
E _pytest.warning_types.RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
E Please use node.get_closest_marker(name) or node.iter_markers(name).
E Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
/usr/local/lib/python3.5/dist-packages/pytest_tornado/plugin.py:98: RemovedInPytest4Warning
我查看了 url 的建议并尝试在网上搜索,但不幸的是我自己一无所获。
测试使用 @pytest.mark.gen_test
装饰器。
那么,有人可以对此有所说明吗?如何让这些测试再次通过?
我用 pytest-tornado-yen3==0.5.2
替换了与 pytest-tornado
相关的问题,但不幸的是 pytest
开始崩溃 ImportError: No module named 'pytest_tornado'
最终我得到了这个。
pip3 uninstall pytest-tornado-yen3 pytest-tornado pytest
pip3 install pytest-tornado-yen3==0.5.2 pytest==4.0.2
问题现在已经解决了。
我有在 pytest 3.8.2 下通过的龙卷风协程测试,但最近我升级到 4.0.2,现在我得到这些测试失败并显示以下消息。
@pytest.mark.tryfirst
def pytest_pyfunc_call(pyfuncitem):
gen_test_mark = pyfuncitem.keywords.get('gen_test')
if gen_test_mark:
io_loop = pyfuncitem.funcargs.get('io_loop')
> run_sync = gen_test_mark.kwargs.get('run_sync', True)
E _pytest.warning_types.RemovedInPytest4Warning: MarkInfo objects are deprecated as they contain merged marks which are hard to deal with correctly.
E Please use node.get_closest_marker(name) or node.iter_markers(name).
E Docs: https://docs.pytest.org/en/latest/mark.html#updating-code
/usr/local/lib/python3.5/dist-packages/pytest_tornado/plugin.py:98: RemovedInPytest4Warning
我查看了 url 的建议并尝试在网上搜索,但不幸的是我自己一无所获。
测试使用 @pytest.mark.gen_test
装饰器。
那么,有人可以对此有所说明吗?如何让这些测试再次通过?
我用 pytest-tornado-yen3==0.5.2
替换了与 pytest-tornado
相关的问题,但不幸的是 pytest
开始崩溃 ImportError: No module named 'pytest_tornado'
最终我得到了这个。
pip3 uninstall pytest-tornado-yen3 pytest-tornado pytest
pip3 install pytest-tornado-yen3==0.5.2 pytest==4.0.2
问题现在已经解决了。