I am trying to run my pytest parameterised tests.
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
However when I do I get this error in 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.
Note that the error is non-fatal and the rest of the program executes without fail.
Why is numberOfSmall being considered a fixture? The same name is not being used as a function name.
>Solution :
It looks like testConfiguration is considered a test due to the name you have given it. All arguments you pass to a test are considered as fixtures if they don’t come from a parameterization as in your test example. To solve it, just rename your function to getTesttestConfiguration() or so.
As a side note, in python it is common to use snail case notation, not camel case notation as you have chosen.