-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Why cant decorator parametrize automatically get function's arguments? #1742
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
Comments
You can also mix fixtures and parametrization - sure, pytest could just assume everything which isn't a fixture is parametrized, but that sounds error-prone. |
the parameterize mark is independent of the test function, it could also be used in a global mark, or in a class level mark |
A quick example of the latter, from pytest's own test suite: @pytest.mark.parametrize('flavor', ['fixture', 'yield_fixture'])
class TestContextManagerFixtureFuncs:
def test_simple(self, testdir, flavor):
...
def test_scoped(self, testdir, flavor):
... |
@nitrocode I know I'm quite late with this, but probably you (or somebody else who stumbles upon this) might still find this useful. I totally agree that the argument names should be deduced automatically. I asked for this in #518 and I suggested an implementation in #780. Sadly, this wasn't accepted, but I got some help for implementing this as an extension: https://github.com/mgeier/pytest-auto-parametrize/ I still hope that it (or something similar) gets included in core |
@mgeier i propose adding a section about it in the docs then as pr while its properties cant correctly work in various interactions with parameterization from different souses its still helpful for people |
I don't understand why a pytest's test function's params have to be manually kept consistent using the pytest.mark.parametrize function.
Isn't there a way for pytest to automatically grab the arguments
("fileName", "fields", "thresh", "companies")
and assume that the fields provided(fileNameA, fileNameAFields, 5, False)
are in the correct order to feed it intotest_me()
?The text was updated successfully, but these errors were encountered: