【发布时间】:2022-01-18 08:39:46
【问题描述】:
我正在尝试运行我的 pytest 参数化测试。
def testConfiguration(numberOfSmall, numberOfMedium, numberOfLarge,numaValue):
...
@pytest.mark.parametrize("small, medium, large, numaValue, out", [
(0,0,1,0,True),
(0,0,1,1,True),
(0,0,2,0,True),
(1,1,1,0,True),
(0,1,1,0,True),
(1,0,1,0,True),
(0,1,0,0,True),
(0,1,0,1,True),
(0,2,0,0,True),
(2,2,0,0,True),
(2,1,0,0,True),
(1,0,0,0,True),
(1,0,0,1,True),
(2,0,0,0,True),
(2,0,0,1,True),
(3,0,0,0,True),
(3,0,0,1,True),
(4,0,0,0,True),
(4,1,0,0,True),
(5,0,0,0,True),
(6,0,0,0,True),
])
def testAll(small, medium, large, numaValue, out):
assert testConfiguration(small, medium, large, numaValue) == out
但是,当我这样做时,我在 pytest 中收到此错误。
E fixture 'numberOfSmall' not found
> available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_xml_attribute, record_xml_property, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
请注意,该错误是非致命的,程序的其余部分将正常执行。
为什么 numberOfSmall 被视为固定装置?同名没有被用作函数名。
【问题讨论】:
标签: python python-2.7 pytest