You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ flake8 --pytest-parametrize-names-type tuple simple_test.py
simple_test.py:21:2: PT006 wrong name(s) type in @pytest.mark.parametrize, expected string
If I asked for tuples, why am I bothered with strings ?
How it should work
If I ask for tuples as parameter names, there should not be any interpretation on the flake8-pytest-style side, it should only check that what I asked for is what it finds in the code:
# Assume this file is named simple_test.pyimportpytest# A string@pytest.mark.parametrize('single_param', (pytest.param('hello'),))deftest1(single_param):
pass# ``('single_param')`` is not a tuple, it is a parenthesized str, hence a str.@pytest.mark.parametrize(('single_param'), (pytest.param('hello'),))deftest2(single_param):
pass# A 1 str tuple@pytest.mark.parametrize(('single_param', ), (pytest.param('hello'),))deftest3(single_param):
pass# A 2 str tuple (to show that tuple length seem to be the matter)@pytest.mark.parametrize(('single_param', 'two value'), (pytest.param('hello'),))deftest4(single_param):
pass
Then run:
$ flake8 --pytest-parametrize-names-type tuple simple_test.py
simple_test.py:21:2: PT006 wrong name(s) type in @pytest.mark.parametrize, expected string
An issue is reported only for the one valid syntax. More over the error is confusing: I ask for tuples, I am told I should have strings.
System information
Operating system:
Python version:
flake8 version:
flake8-pytest-style version:
The text was updated successfully, but these errors were encountered:
The way I see it, the names structure is "parallel" to the values. In the first example the values are wrapped in tuples ((1, 2) etc), and the names are correspondingly wrapped in a tuple. In the second example the individual values are not wrapped, so the name is also a plain string not wrapped in a list/tuple.
All things said, I could be open to introducing a new config option which would force single names to conform to the same style as multiple names. Unfortunately I am not sure when I will have time to implement it myself, but pull requests are always welcome.
Bug report
What's wrong
If I asked for tuples, why am I bothered with strings ?
How it should work
If I ask for tuples as parameter names, there should not be any interpretation on the flake8-pytest-style side, it should only check that what I asked for is what it finds in the code:
Then run:
An issue is reported only for the one valid syntax. More over the error is confusing: I ask for tuples, I am told I should have strings.
System information
The text was updated successfully, but these errors were encountered: