Skip to content

Parametrized argument named similarly to fixture (contains it) breaks that fixture's parametrization #736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pytestbot opened this issue May 4, 2015 · 0 comments
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Jacobo Giralt (BitBucket: jgiralt, GitHub: jgiralt)


#!python

import pytest

@pytest.fixture(params=[1,2,3])
def foo(request):
    return request.param

@pytest.mark.parametrize('foobar', [4,5,6])
def test_issue(foo, foobar):
    assert True
#!python

request = <SubRequest 'foo' for <Function 'test_issue[4]'>>

    @pytest.fixture(params=[1,2,3])
    def foo(request):
>       return request.param
AttributeError: SubRequest instance has no attribute 'param'

The issue seems reproducible as long as the parametrized test argument contains the fixture name as a substring, e.g. foobar, barfoo, foox, xfoo, disappears as soon as I modify the fixture name to anything else.

This same code works in pytest-2.6.4 and fails for 2.7.


@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
@pfctdayelise pfctdayelise added the topic: parametrize related to @pytest.mark.parametrize label Jul 25, 2015
untitaker added a commit to untitaker/pytest that referenced this issue Aug 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

2 participants