Pytest AttributeError: ‘Function’ object has no attribute ‘get_marker’
发布时间:2021-03-01T15:38:05:手机请访问
报错如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
(base) ➜ cases pytest login ======================================= test session starts ======================================== platform darwin -- Python 3.7.0, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 rootdir: /Users/songhao/py/py_test/cases plugins: arraydiff-0.2, doctestplus-0.1.3, html-3.1.1, metadata-1.11.0, openfiles-0.3.0, remotedata-0.3.0 collected 2 items login/test_lg.py EE [100%] ============================================== ERRORS ============================================== _______________________________ ERROR at setup of Test_demo.test_001 _______________________________ item = <Function test_001> def pytest_runtest_setup(item): > remote_data = item.get_marker('remote_data') E AttributeError: 'Function' object has no attribute 'get_marker' ../../../anaconda3/lib/python3.7/site-packages/pytest_remotedata/plugin.py:64: AttributeError _______________________________ ERROR at setup of Test_demo.test_002 _______________________________ item = <Function test_002> def pytest_runtest_setup(item): > remote_data = item.get_marker('remote_data') E AttributeError: 'Function' object has no attribute 'get_marker' ../../../anaconda3/lib/python3.7/site-packages/pytest_remotedata/plugin.py:64: AttributeError ===================================== short test summary info ====================================== ERROR login/test_lg.py::Test_demo::test_001 - AttributeError: 'Function' object has no attribute ... ERROR login/test_lg.py::Test_demo::test_002 - AttributeError: 'Function' object has no attribute ... ======================================== 2 errors in 0.09s ========================================= |
解决方法:
当前 pytest 版本 pytest 6.2.2, pytest-remotedata 即可
版本过低导致的,在 pytest 4.6 后版本改写了个方法造成的
更新 pytest-remotedata 即可
1 |
pip install -U pytest-remotedata |
更新完成以后就可以正常运行了
