[英]pytest can't find pytest.fixture_request
I am attempting to utilize the alternative approach listed in the PyTest documentation here. 我正在尝试利用此处PyTest文档中列出的替代方法 。 My parametrize
decorator call looks like this 我的parametrize
装饰器调用看起来像这样
@pytest.mark.parametrize("val1, params, result", [
('a string', pytest.fixture_request('valid_type'), 150)
])
However, when I run pytest
I get the following error: 但是,当我运行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'
The valid_type
fixture does exist. valid_type
固定装置确实存在。
I am running pytest version 3.2.0 我正在运行pytest版本3.2.0
How can I solve this problem, so that I can utilize the 'alternative approach' listed in the documentation above? 如何解决此问题,以便可以利用上面文档中列出的“替代方法”?
The described approach is only a proposal that has not been implemented yet (as you can see in this discussion: https://github.com/pytest-dev/pytest/issues/349#issuecomment-286451346 ). 所描述的方法只是尚未实施的建议(如您在本讨论中所看到的: https : //github.com/pytest-dev/pytest/issues/349#issuecomment-286451346 )。 As a workaround, you can use the package pytest-lazy-fixture
(can be installed with pip
): instead of pytest.fixture_request('fixture_name')
just use pytest.lazy_fixture('fixture_name')
. 解决方法是,您可以使用pytest-lazy-fixture
包(可以与pip
一起安装):代替pytest.fixture_request('fixture_name')
只需使用pytest.lazy_fixture('fixture_name')
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.