简体   繁体   English

如何修复此 AttributeError: 'SubRequest' object 没有属性 'getfuncargvalue'?

[英]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

From your error messages, you are using Python3.7.从您的错误消息中,您使用的是 Python3.7。

It is possible that you are using the deprecated getfuncargvalue instead of getfixturevalue as described here .您可能正在使用已弃用的getfuncargvalue而不是getfixturevalue ,如此所述。

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.

相关问题 我该如何解决这个 AttributeError: 'NoneType' object has no attribute 'text'? - How do i fix this AttributeError: 'NoneType' object has no attribute 'text'? 我该如何修复 AttributeError: 'Tk' object has no attribute 'open' - how do I fix AttributeError: 'Tk' object has no attribute 'open' 如何修复 AttributeError: 'NoneType' object 没有属性 'lower'? - How do i fix AttributeError: 'NoneType' object has no attribute 'lower'? 如何修复 AttributeError: &#39;bytes&#39; object has no attribute &#39;encode&#39;? - How do I fix AttributeError: 'bytes' object has no attribute 'encode'? 我收到一条错误消息,指出 AttributeError: &#39;str&#39; object has no attribute &#39;read&#39;,我不知道如何修复它 - I'm getting an error that says AttributeError: 'str' object has no attribute 'read' and i do not know how to fix it 我该如何修复,AttributeError: 'NoneType' 对象没有属性 'send' - How can I fix, AttributeError: 'NoneType' object has no attribute 'send' 如何解决错误“ AttributeError:&#39;pygame.Surface&#39;对象没有属性&#39;units&#39;”? - How do I fix the error “AttributeError: 'pygame.Surface' object has no attribute 'units'”? AttributeError:“ tuple”对象没有属性“ append”是什么,如何修复我的代码? - What does AttributeError: 'tuple' object has no attribute 'append' and how do I fix my code? 尝试使用 moviepy 编写 CompositeVideoClip 时,如何修复“AttributeError:‘NoneType’对象没有属性‘stdout’”? - How do I fix "AttributeError: 'NoneType' object has no attribute 'stdout'" when trying to write a CompositeVideoClip with moviepy? 我该如何解决这个 pygame 错误 AttributeError: 'Bullet' object has no attribute 'rect' - how do i fix this pygame error AttributeError: 'Bullet' object has no attribute 'rect'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM