[英]How do I fix this AttributeError: 'SubRequest' object has no attribute 'getfuncargvalue'?
I am taking the MongoDB for Python Developers course at Mongo University but I have this problem when trying to run pytest -m connection on a computer mac:我正在 Mongo 大学参加 MongoDB 的 Python 开发人员课程,但是当我尝试在计算机 mac 上运行 pytest -m 连接时遇到了这个问题:
tests/test_db_connection.py EEEE [100%]测试/test_db_connection.py EEEE [100%]
=========================================================== ERRORS =========================================================== _____________________________________________ ERROR at setup of test_atlas_setup _____________________________________________ ==================================================== ========= 错误 ========================================= =================== _____________________________________________ 设置 test_atlas_setup 时出错 _____________________________________________
request = > monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10c838cd0>请求 = > monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10c838cd0>
@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
"""Use `pytest.mark.options` decorator to pass options to your application
factory::
@pytest.mark.options(debug=False)
def test_something(app):
assert not app.debug, 'the application works not in debug mode!'
"""
if 'app' not in request.fixturenames:
return
app = request.getfuncargvalue('app')
E AttributeError: 'SubRequest' object has no attribute 'getfuncargvalue'
E AttributeError: 'SubRequest' object 没有属性 'getfuncargvalue'
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError ____________________________________________ ERROR at setup of test_basic_movies _____________________________________________ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError ____________________________________________ 设置 test_basic_movies 时出错 _____________________________________________
request = > monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10c893610>请求 = > monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10c893610>
@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
"""Use `pytest.mark.options` decorator to pass options to your application
factory::
@pytest.mark.options(debug=False)
def test_something(app):
assert not app.debug, 'the application works not in debug mode!'
"""
if 'app' not in request.fixturenames:
return
app = request.getfuncargvalue('app')
E AttributeError: 'SubRequest' object has no attribute 'getfuncargvalue'
E AttributeError: 'SubRequest' object 没有属性 'getfuncargvalue'
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError _________________________________________ ERROR at setup of test_search_by_movie_id __________________________________________ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError _________________________________________ 设置 test_search_by_movie_id 时出错 __________________________________________
request = > monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10c87c750>请求 = > monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10c87c750>
@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
"""Use `pytest.mark.options` decorator to pass options to your application
factory::
@pytest.mark.options(debug=False)
def test_something(app):
assert not app.debug, 'the application works not in debug mode!'
"""
if 'app' not in request.fixturenames:
return
app = request.getfuncargvalue('app')
E AttributeError: 'SubRequest' object has no attribute 'getfuncargvalue'
E AttributeError: 'SubRequest' object 没有属性 'getfuncargvalue'
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError _________________________________________ ERROR at setup of test_simple_text_search __________________________________________ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError _________________________________________ 设置 test_simple_text_search 时出错 __________________________________________
request = > monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10c838ed0>请求 = > monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x10c838ed0>
@pytest.fixture(autouse=True)
def _configure_application(request, monkeypatch):
"""Use `pytest.mark.options` decorator to pass options to your application
factory::
@pytest.mark.options(debug=False)
def test_something(app):
assert not app.debug, 'the application works not in debug mode!'
"""
if 'app' not in request.fixturenames:
return
app = request.getfuncargvalue('app')
E AttributeError: 'SubRequest' object has no attribute 'getfuncargvalue'
E AttributeError: 'SubRequest' object 没有属性 'getfuncargvalue'
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109:AttributeError
Try to update the dependencies of the project, the default dependencies of Pytest, pymongo and Flask are quite old.尝试更新项目的依赖,Pytest、pymongo和Flask的默认依赖都比较老了。 I managed to get the tests passing after updating them.
在更新它们后,我设法让测试通过。
Same happened to me.我也发生了同样的事情。 I added attrs==19.1.0 to requirements.txt and it worked!
我将 attrs==19.1.0 添加到 requirements.txt 并且它有效!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.