-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Error using parametrize with default arguments #3221
Comments
pytest doesnt consider arguments with default values as targets for fixtures/parameterization |
Yes, that is the root cause. But this isn't a question; my point is that the error is completely confusing and the solution non-obvious unless you read the source code:
and then complains that there is no argument. So I'd consider it either a bug with error messages, argument-as-potential-fixture classification (although I assume this was rigorously discussed in the past and is like this for a reason), or a documentation problem. |
thanks for expressing what you need for better understanding of the issue |
As I can see pytest ignores arguments with default values: Lines 112 to 115 in e7bcc85
Do we need to raise exception here? In this case all arguments with default value will catch this error |
that function in particular is working exactly as documented, so just raising an error there is not a good way to sort it out |
With pytest 3.4.0:
You get the error:
It seems pytest is separating the concept of normal python arguments and 'fixtures' here, only classifying only default-free arguments as potential fixtures - and then only considering 'fixtures' as valid targets for parametrisation - but the error message completely obfuscates this: by any regular python interpretation the function definitely has an argument 'something'.
The documentation on this - https://docs.pytest.org/en/latest/parametrize.html doesn't show this as an example but also doesn't mention that it's a constraint; it's only through reading the pytest source that I could work out what the problem was.
Related: The wording of this was changed to 'argument' from 'fixture' in #1539 which makes sense in the context of that error, but only confuses this one.
The text was updated successfully, but these errors were encountered: