I want to divide the instruments between different instances of the same parameterized tests, where the instruments themselves are also parameterized:
I get this output:
platform linux -- Python 3.4.1 -- py-1.4.26 -- pytest-2.6.4 -- /usr/bin/python collecting ... collected 8 items test.py::test_a[1] test_a: fixture_1(1) PASSED test.py::test_b[1] test_b: fixture_1(1) PASSED test.py::test_c[1-0] test_c[0]: fixture_1(1) PASSED test.py::test_c[1-1] test_c[1]: fixture_1(2) PASSED test.py::test_c[1-2] test_c[2]: fixture_1(3) PASSED test.py::test_d[0] test_d[0]: fixture_2(4) PASSED test.py::test_d[1] test_d[1]: fixture_2(4) PASSED test.py::test_d[2] test_d[2]: fixture_2(4) PASSED
test_a , test_b and test_c[0] all share fixture_1(1) . All test_d exchange fixture_2(4) . The problem is that test_c use different versions of fixture_1 .
This also happens when the scopes are defined as โmoduleโ and โclassโ, and this only happens when parameterizing both the test and the instrument.
From the way pytest prints the parameters of testr, it seems that it does not distinguish between the different types of parameters used for each element, so it creates a binding for each set of parameters, and not for each unique subset of parameters the list that the device uses.
Is this a bug in pytest, or have I neglected setting any configuration or something else? Is there a workaround?
source share