我正在尝试使用此处 PyTest 文档中列出的替代方法。我的parametrize装饰器调用看起来像这样
@pytest.mark.parametrize("val1, params, result", [
('a string', pytest.fixture_request('valid_type'), 150)
])
Run Code Online (Sandbox Code Playgroud)
但是,当我运行时,出现pytest以下错误:
test_get_responses.py:102: in <module>
('a string', pytest.fixture_request('valid_type'), 150)
E AttributeError: 'module' object has no attribute 'fixture_request'
Run Code Online (Sandbox Code Playgroud)
该valid_type夹具确实存在。
我正在运行 pytest 版本 3.2.0
我该如何解决这个问题,以便我可以利用上面文档中列出的“替代方法”?
小智 5
所描述的方法只是尚未实施的提案(如您在此讨论中所见:https : //github.com/pytest-dev/pytest/issues/349#issuecomment-286451346)。作为一种解决方法,您可以使用软件包pytest-lazy-fixture(可以与 一起安装pip):而不是pytest.fixture_request('fixture_name')仅使用pytest.lazy_fixture('fixture_name').
| 归档时间: |
|
| 查看次数: |
1664 次 |
| 最近记录: |