【问题标题】:How do I fix this AttributeError: 'SubRequest' object has no attribute 'getfuncargvalue'?如何修复此 AttributeError:“SubRequest”对象没有属性“getfuncargvalue”?
【发布时间】:2020-03-11 21:39:21
【问题描述】:

我正在 Mongo 大学参加 MongoDB for Python Developers 课程,但尝试在计算机 mac 上运行 pytest -m 连接时遇到了这个问题:

tests/test_db_connection.py EEEE [100%]

================================================ ============ 错误 ===================================== ======================= _____________________________________________ 设置 test_atlas_setup 时出错 _____________________________________________

请求 = > monkeypatch = <_pytest.monkeypatch.monkeypatch>

@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' 对象没有属性 'getfuncargvalue'

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109:AttributeError _______________________________________ 设置 test_basic_movies 时出错 _____________________________________________

请求 = > monkeypatch = <_pytest.monkeypatch.monkeypatch>

@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' 对象没有属性 'getfuncargvalue'

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109:AttributeError _________________________________________ 设置 test_search_by_movie_id 时出错 ___________________________________________

请求 = > monkeypatch = <_pytest.monkeypatch.monkeypatch>

@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' 对象没有属性 'getfuncargvalue'

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109:AttributeError _________________________________________ 设置 test_simple_text_search 时出错 __________________________________________

请求 = > monkeypatch = <_pytest.monkeypatch.monkeypatch>

@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' 对象没有属性 'getfuncargvalue'

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytest_flask/plugin.py:109: AttributeError

【问题讨论】:

    标签: python python-3.x mongodb


    【解决方案1】:

    根据您的错误消息,您使用的是 Python3.7。

    您可能正在使用已弃用的getfuncargvalue 而不是getfixturevalue,如here 所述。

    【讨论】:

      【解决方案2】:

      同样的事情发生在我身上。我将 attrs==19.1.0 添加到 requirements.txt 并且它起作用了!

      【讨论】:

      • 很高兴知道:)
      【解决方案3】:

      尝试更新项目的依赖,Pytest、pymongo和Flask的默认依赖都比较老了。更新后我设法让测试通过了。

      【讨论】:

      • 更新所有软件包并解决了兼容性问题,但没有奏效
      猜你喜欢
      • 1970-01-01
      • 2021-04-20
      • 2021-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多