Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pytest can';找不到pytest.fixture\u请求_Python_Pytest - Fatal编程技术网

Python pytest can';找不到pytest.fixture\u请求

Python pytest can';找不到pytest.fixture\u请求,python,pytest,Python,Pytest,我试图利用PyTest文档中列出的。我的parametrizedecorator调用如下所示 @pytest.mark.parametrize("val1, params, result", [ ('a string', pytest.fixture_request('valid_type'), 150) ]) 但是,当我运行pytest时,会出现以下错误: test_get_responses.py:102: in <module> ('a string', p

我试图利用PyTest文档中列出的。我的
parametrize
decorator调用如下所示

@pytest.mark.parametrize("val1, params, result", [
    ('a string', pytest.fixture_request('valid_type'), 150)

])
但是,当我运行
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'
test\u get\u responses.py:102:in
('a string',pytest.fixture_请求('valid_type'),150)
E AttributeError:“模块”对象没有“夹具请求”属性
有效的\u类型
夹具不存在

我正在运行pytest版本3.2.0


如何解决此问题,以便利用上述文档中列出的“替代方法”?

所述方法只是一个尚未实施的方案(如您在本讨论中所见:)。作为一种解决方法,您可以使用包
pytest lazy fixture
(可以与
pip
一起安装):而不是
pytest.fixture\u请求('fixture\u name')
只需使用
pytest.lazy\u fixture('fixture\u name')