New issue 570: indirect=True in parametrize breaks fixture scopes https://bitbucket.org/hpk42/pytest/issue/570/indirect-true-in-parametrize-breaks
Ivan Kalinin: The following test: ``` #!python import pytest @pytest.fixture(scope='class') def my_profile(request): print 'Setting up profile with param', getattr(request, 'param', 'Nothing') @pytest.mark.parametrize('my_profile', ['pewpew', 'ololo'], indirect=True) class TestClassOne: def test_foo(self, my_profile): pass def test_bar(self, my_profile): pass ``` Outputs this: ``` #!text (pytest)pupssman@dirigible:~$ py.test test_1.py -sv ================================================ test session starts ================================================= platform linux2 -- Python 2.7.4 -- py-1.4.23 -- pytest-2.6.1 -- /home/pupssman/venv/pytest/bin/python plugins: qabs-yadt, allure-adaptor, contextfixture, capturelog, xdist collected 4 items test_1.py::TestClassOne::test_foo[pewpew] Setting up profile with param pewpew PASSED test_1.py::TestClassOne::test_foo[ololo] Setting up profile with param ololo PASSED test_1.py::TestClassOne::test_bar[pewpew] Setting up profile with param pewpew PASSED test_1.py::TestClassOne::test_bar[ololo] Setting up profile with param ololo PASSED ============================================== 4 passed in 0.01 seconds ============================================== ``` Looks like it sets the fixture up for each test method of class independently. However, the declaration of ```scope='class'``` should force py.test to set the fixture up only once for each parameter value for the test class. I.e., the output should be something like that: ``` #!text (pytest)pupssman@dirigible:~$ py.test test_1.py -sv ================================================ test session starts ================================================= platform linux2 -- Python 2.7.4 -- py-1.4.23 -- pytest-2.6.1 -- /home/pupssman/venv/pytest/bin/python plugins: qabs-yadt, allure-adaptor, contextfixture, capturelog, xdist collected 4 items test_1.py::TestClassOne::test_foo[pewpew] Setting up profile with param pewpew PASSED test_1.py::TestClassOne::test_bar[pewpew] PASSED test_1.py::TestClassOne::test_foo[ololo] Setting up profile with param ololo PASSED test_1.py::TestClassOne::test_bar[ololo] PASSED ============================================== 4 passed in 0.01 seconds ============================================== ``` _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit