前言
测试用例参数化的时候,使用 pytest.mark.parametrize 参数化传测试数据,如果我们想引用前面 不同fixture 返回的数据当测试用例的入参,前面一篇用fixture 参数化 prams 来间接解决这个问题。
接下来用 pytest-lazy-fixture 插件可以直接在测试用例中参数化时 pytest.mark.parametrize 中使用 fixture
pytest-lazy-fixture 插件
pytest-lazy-fixture 插件是为了解决测试用例中用 @pytest.mark.parametrize 参数化调用fixture的问题,先pip安装
pip install pytest-lazy-fixture
目前使用的版本是 0.6.3
>pip show pytest-lazy-fixture
Name: pytest-lazy-fixture
Version: 0.6.3
Summary: It helps to use fixtures in pytest.mark.parametrize
Home-page: https://github.com/tvorog/pytest-lazy-fixture
Author: Marsel Zaripov
Author-email: marszaripov@gmail.com
License: MIT
Location: e:\python36\lib\site-packages
Requires: pytest
Required-by:
parametrize 使用示例
参数化的时候,其中一些测试数据,来源于前面的 fixture
i