簡體   English   中英

pytest找不到pytest.fixture_request

[英]pytest can't find pytest.fixture_request

我正在嘗試利用此處PyTest文檔中列出的替代方法 我的parametrize裝飾器調用看起來像這樣

@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'

valid_type固定裝置確實存在。

我正在運行pytest版本3.2.0

如何解決此問題,以便可以利用上面文檔中列出的“替代方法”?

所描述的方法只是尚未實施的建議(如您在本討論中所看到的: https : //github.com/pytest-dev/pytest/issues/349#issuecomment-286451346 )。 解決方法是,您可以使用pytest-lazy-fixture包(可以與pip一起安裝):代替pytest.fixture_request('fixture_name')只需使用pytest.lazy_fixture('fixture_name')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM