Skip to content
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

Better message in case of not using parametrized variable #1539

Closed
pwilczynskiclearcode opened this issue Apr 28, 2016 · 5 comments
Closed
Labels
good first issue easy issue that is friendly to new contributor status: help wanted developers would like help from experts on this topic topic: parametrize related to @pytest.mark.parametrize topic: reporting related to terminal output and user-facing messages and errors

Comments

@pwilczynskiclearcode
Copy link
Contributor

py.test 2.9.1

In case of not using one of parametrized variables the following message is displayed:

/python2.7/site-packages/_pytest/python.py:237: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
/python2.7/site-packages/_pytest/python.py:1000: in parametrize
    raise ValueError("%r uses no fixture %r" %(self.function, arg))
E   ValueError: <function test_abc at 0x7f9bb394dde8> uses no fixture u'suffix'

where suffix isn't a fixture but missed variable from pytest.mark.parametrize.

Suggested enhancement: Raise Exception with a message suggesting using the suffix variable and not confuse developers about suffix fixture.

@The-Compiler
Copy link
Member

It is a fixture from pytest's point of view - but I'd also be okay with the error saying "argument" instead of "fixture". "variable" is even more confusing, IMHO.

@RonnyPfannschmidt RonnyPfannschmidt added status: help wanted developers would like help from experts on this topic topic: reporting related to terminal output and user-facing messages and errors good first issue easy issue that is friendly to new contributor topic: parametrize related to @pytest.mark.parametrize labels Apr 28, 2016
@RonnyPfannschmidt
Copy link
Member

for parametrize, in case of direct "arguments" we should use names that make the most sense

for a good error we should take a look if there is a indirect fixture that takes parameters (needs indirect=True) or if the parameter is just missing (maybe typo detection)

@hackebrot
Copy link
Member

I'd say we change the ValueError to report an issue

  • with argument if parameter is not indirect
  • with fixture if parameter is indirect

jjanczyszyn added a commit to jjanczyszyn/pytest that referenced this issue Jul 23, 2016
@hackebrot
Copy link
Member

Please review #1757

@nicoddemus
Copy link
Member

Fixed in #1757

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor status: help wanted developers would like help from experts on this topic topic: parametrize related to @pytest.mark.parametrize topic: reporting related to terminal output and user-facing messages and errors
Projects
None yet
Development

No branches or pull requests

5 participants