python - 将参数化夹具与 pytest 中的参数化测试相关联
问题描述
我想在 pytest 中做类似的事情(这只是一个简化的例子):
import pytest
@pytest.fixture(params=['A', 'B'])
def fixture1(request):
return request.param.lower()
@pytest.mark.parametrize("extra_arg1", ["1", "2"])
def test_xxx(fixture1, extra_arg1):
assert fixture1 + extra_arg1 == .....
# the test is expected to run 4 times and the results should be "a1", "b1", "a2", "b2"
如何将参数化夹具与测试中的参数相关联?注意:我必须使用fixture,因为它已经在项目回购中到位。
谢谢!
解决方案
推荐阅读
- typescript - Type-GraphQL 将分页对象添加到解析器
- node.js - 使用 ApolloWebserver 时无法在 GraphQL 架构中使用 @cypher
- jquery - jquery获取元素的值
- reactjs - 无法使用 React Router 访问来自 Api 的详细信息,而不会在页面上呈现
- swift - 符合具有关联值的类型的协议
- sql-server - 在 SQL 中透视具有多列的表
- scala - Scala replaceAllIn 无法正常工作?
- sql - 有没有办法选择多行但只返回不同的列?
- android - Andoid webview 自己的服务器
- c - Sorting matrix by even numbers in rows