Skip to content

Commit d000f25

Browse files
committed
added a test for when the indirect is just a string
1 parent bbc7f3a commit d000f25

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,7 @@ time or change existing behaviors in order to make them less surprising/more use
145145
* Allow passing a custom debugger class (e.g. ``--pdbcls=IPython.core.debugger:Pdb``).
146146
Thanks to `@anntzer`_ for the PR.
147147

148-
149-
* Better message in case of not using parametrized variable (see `#1539`_).
150-
Thanks to `@tramwaj29`_ for the PR.
148+
*
151149

152150
*
153151

@@ -234,6 +232,9 @@ time or change existing behaviors in order to make them less surprising/more use
234232

235233
* ``optparse`` backward compatibility supports float/complex types (`#457`_).
236234

235+
* Better message in case of not using parametrized variable (see `#1539`_).
236+
Thanks to `@tramwaj29`_ for the PR.
237+
237238
*
238239

239240
*

_pytest/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None,
804804
if isinstance(indirect, (tuple, list)):
805805
name = 'fixture' if arg in indirect else 'argument'
806806
else:
807-
name = 'fixture' if indirect is True else 'argument'
807+
name = 'fixture' if indirect else 'argument'
808808
raise ValueError(
809809
"%r uses no %s %r" % (
810810
self.function, name, arg))

testing/python/metafunc.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,23 @@ def test_simple(x):
417417
"*uses no fixture 'y'*",
418418
])
419419

420+
@pytest.mark.issue714
421+
def test_parametrize_indirect_uses_no_fixture_error_indirect_string(self, testdir):
422+
testdir.makepyfile("""
423+
import pytest
424+
@pytest.fixture(scope='function')
425+
def x(request):
426+
return request.param * 3
427+
428+
@pytest.mark.parametrize('x, y', [('a', 'b')], indirect='y')
429+
def test_simple(x):
430+
assert len(x) == 3
431+
""")
432+
result = testdir.runpytest("--collect-only")
433+
result.stdout.fnmatch_lines([
434+
"*uses no fixture 'y'*",
435+
])
436+
420437
@pytest.mark.issue714
421438
def test_parametrize_indirect_uses_no_fixture_error_indirect_list(self, testdir):
422439
testdir.makepyfile("""

0 commit comments

Comments
 (0)