New issue 447: Fixture params not accessible inside the fixture, not getting called multiple times. https://bitbucket.org/hpk42/pytest/issue/447/fixture-params-not-accessible-inside-the
Paul Oswald: Parametrize decorator will not pass parameters into methods that are on subclasses of TestCase. There is a note at the bottom of http://pytest.org/latest/unittest.html#autouse-fixtures-and-accessing-other-fixtures explaining that this behaviour is intentional. I fully understand the logic behind that but I have quite a few tests that already are written in a way such that the methods accept (self, data) args by using a nose plugin. I need a function that works exactly like the parametrize decorator but will call TestCase methods. In an attempt to work around this issue, I created the following proof of concept but it seems to have some issues: ``` #!python from django.test import TestCase import pytest data_list = [ {"1": 1}, {"2": 2}, ] @pytest.fixture(scope='function', params=data_list) def my_data(request): print request.param @pytest.mark.usefixtures("my_data") class TestParameterizedTest(TestCase): def test_passing(self): assert 1 == 1 def test_multiple(self): print self.my_data assert 1 == 2 ``` When this runs request.param is not defined. Also, request.param [is mentioned](http://pytest.org/latest/fixture.html#parametrizing-a-fixture) in the docs but [not really listed](http://pytest.org/latest/builtin.html#_pytest.python.FixtureRequest) in the request api. ``` request = <SubRequest 'my_data' for <TestCaseFunction 'test_passing'>> @pytest.fixture(scope='function', params=data_list) def my_data(request): > print request.param E AttributeError: SubRequest instance has no attribute 'param' ``` Also, even if you don't try to access request.param, I expected this to parametrize into 2 tests and it doesn't seem to recognise it as being parameterized. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit