-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Improved message when not using parametrized variable #1757
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
Merged
nicoddemus
merged 5 commits into
pytest-dev:features
from
jjanczyszyn:improved-message-when-not-using-parametrized-variable
Jul 24, 2016
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f26fa5a
changed error message for unused parametrize name
jjanczyszyn 3631719
added myself to authors
jjanczyszyn bbc7f3a
updated changelog, resolve #1539
jjanczyszyn d000f25
added a test for when the indirect is just a string
jjanczyszyn 4aede6f
fixed conflicts
jjanczyszyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,7 +394,7 @@ def test_simple(x): | |
""") | ||
result = testdir.runpytest("--collect-only") | ||
result.stdout.fnmatch_lines([ | ||
"*uses no fixture 'y'*", | ||
"*uses no argument 'y'*", | ||
]) | ||
|
||
@pytest.mark.issue714 | ||
|
@@ -425,7 +425,7 @@ def test_parametrize_indirect_uses_no_fixture_error_indirect_list(self, testdir) | |
def x(request): | ||
return request.param * 3 | ||
|
||
@pytest.mark.parametrize('x, y', [('a', 'b')], indirect=['x']) | ||
@pytest.mark.parametrize('x, y', [('a', 'b')], indirect=['y']) | ||
def test_simple(x): | ||
assert len(x) == 3 | ||
""") | ||
|
@@ -434,6 +434,23 @@ def test_simple(x): | |
"*uses no fixture 'y'*", | ||
]) | ||
|
||
@pytest.mark.issue714 | ||
def test_parametrize_argument_not_in_indirect_list(self, testdir): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have a test when @pytest.mark.issue714
def test_parametrize_argument_not_in_indirect_list(self, testdir):
for decl in ("['x']", "'x'"):
testdir.makepyfile("""
import pytest
@pytest.fixture(scope='function')
def x(request):
return request.param * 3
@pytest.mark.parametrize('x, y', [('a', 'b')], indirect={decl}
def test_simple(x):
assert len(x) == 3
""".format(decl=decl))
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*uses no argument 'y'*",
]) It is a shame that we can't use parametrize here (we try to avoid using parametrize in this test module); |
||
testdir.makepyfile(""" | ||
import pytest | ||
@pytest.fixture(scope='function') | ||
def x(request): | ||
return request.param * 3 | ||
|
||
@pytest.mark.parametrize('x, y', [('a', 'b')], indirect=['x']) | ||
def test_simple(x): | ||
assert len(x) == 3 | ||
""") | ||
result = testdir.runpytest("--collect-only") | ||
result.stdout.fnmatch_lines([ | ||
"*uses no argument 'y'*", | ||
]) | ||
|
||
def test_addcalls_and_parametrize_indirect(self): | ||
def func(x, y): pass | ||
metafunc = self.Metafunc(func) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the message looks good, I just think it should go under the
Changes
section instead ofNew Features
.