首页 > 解决方案 > 测试。测试参数化不起作用

问题描述

代码如下:

import pytest

@pytest.mark.parametrize("x", [0, 1])
@pytest.mark.parametrize("y", [2, 3])

def test_foo(x, y):
    assert x > y

但是通过运行测试系统给出:

进程以退出代码 0 结束

有人知道为什么它不起作用吗?

标签: pythonpytest

解决方案


试试这个代码:

import pytest
@pytest.mark.parametrize(params=["x", [0, 1]])
def test_foo(x, y): 
    assert x > y

推荐阅读