是否可以将夹具传递给 pytest 生成测试?
import py.test
@py.test.fixture(scope="module")
def fixture():
return True
def test_1(fixture):
def checker(datum):
assert datum == fixture
for i in [True, True, True]:
# Does not work.
yield checker, i
# Does work.
#checker(i)
上面的代码产生
> for i, x in enumerate(self.obj()):
name, call, args = self.getcallargs(x)
E TypeError: test_1() takes exactly 1 argument (0 given)
我们使用 Debian 的 py.test 2.3.5。