【发布时间】:2016-10-01 05:40:27
【问题描述】:
我的参数决定了我的参数化 pytest 的名称。我将为这些测试使用一些随机参数。为了不让 junit 中的报告名称混乱,我想为每个参数化测试创建一个静态名称。
有可能吗?
JUnit好像有个参数:Changing names of parameterized tests
class TestMe:
@pytest.mark.parametrize(
("testname", "op", "value"),
[
("testA", "plus", "3"),
("testB", "minus", "1"),
]
)
def test_ops(self, testname, op, value):
我尝试覆盖request.node.name,但是我只能在测试执行期间重命名它。
我几乎可以肯定我需要编写插件或夹具。您认为解决此问题的最佳方法是什么?
【问题讨论】:
标签: python rename pytest fixtures parameterized