NewGuy
NewGuy

Reputation: 3423

pytest can't find pytest.fixture_request

I am attempting to utilize the alternative approach listed in the PyTest documentation here. My parametrize decorator call looks like this

@pytest.mark.parametrize("val1, params, result", [
    ('a string', pytest.fixture_request('valid_type'), 150)

])

However, when I run pytest I get the following error:

test_get_responses.py:102: in <module>
    ('a string', pytest.fixture_request('valid_type'), 150)
E   AttributeError: 'module' object has no attribute 'fixture_request'

The valid_type fixture does exist.

I am running pytest version 3.2.0

How can I solve this problem, so that I can utilize the 'alternative approach' listed in the documentation above?

Upvotes: 3

Views: 3365

Answers (1)

The described approach is only a proposal that has not been implemented yet (as you can see in this discussion: https://github.com/pytest-dev/pytest/issues/349#issuecomment-286451346). As a workaround, you can use the package pytest-lazy-fixture (can be installed with pip): instead of pytest.fixture_request('fixture_name') just use pytest.lazy_fixture('fixture_name').

Upvotes: 6

Related Questions