[Pytest-commit] Issue #714: Request the feature to apply indirect=True on particular argnames (pytest-dev/pytest)

Alina Berdnikova issues-reply at bitbucket.org
Wed Apr 8 17:00:06 CEST 2015


New issue 714: Request the feature to apply indirect=True on particular argnames
https://bitbucket.org/pytest-dev/pytest/issue/714/request-the-feature-to-apply-indirect-true

Alina Berdnikova:

According to http://pytest.org/latest/parametrize.html#the-metafunc-object, if indirect=True it'll
pass each argvalue to its corresponding fixture function.

It would be great if there was a way to specify which arguments are to be passed as params to corresponding fixtures and which are to be passed directly to test -- for example, via explicitly listing names of those indirectly-parametrized fixtures.
If argument name is listed in indirect= list, but corresponding fixture is nowhere to be found, an error should be raised.
And if the argument not listed in the indirect= clause, it should be passed directly as a test parameter despite corresponding fixture being defined or not.

I'm expecting this code

```
#!python

@pytest.fixture(scope='function')
def bar(request):
    return 'little %s' % request.param


@pytest.fixture(scope='function')
def foo(request):
    return 'great %s' % request.param


@pytest.mark.parametrize('foo, bar, spam', [('ololol', 'lalala', 'cococo'),
                                            ('pewpew', 'pawpaw', 'pafpaf')], 
                                            indirect=('bar', 'foo'))
def test_one(foo, bar, spam):
    print foo, bar, spam
```

to output this:

```
#!python

============================= test session starts ==============================
platform darwin -- Python 2.7.5 -- py-1.4.26 -- pytest-2.6.4 -- /Users/freakbelka/.venv/bin/python
plugins: yadt
collecting ... collected 2 items

test_1.py::test_one[ololol-lalala-cococo] great ololol little lalala cococo
PASSED
test_1.py::test_one[pewpew-pawpaw-pafpaf] great pewpew little pawpaw pafpaf
PASSED
=========================== 2 passed in 2.59 seconds ===========================
```

Responsible: hpk42


More information about the pytest-commit mailing list