pytest如何检查是否有一个变参?

b
bihai
楼主 (未名空间)

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

我在 teardown里面要读取
class Base(object):
def setup_method(self, method):
length = self._item.callspec.getparam('x')
print(length)

但是我在另一个test没有x
@pytest.mark.parametrize("z", [2, 3])
def test_bar(z):
pass

那如何检测callspec是否有x呢?