Merge pull request #1757 from tramwaj29/improved-message-when-not-using-parametrized-variable
Improved message when not using parametrized variable
This commit is contained in:
commit
a24146dd3c
1
AUTHORS
1
AUTHORS
|
@ -65,6 +65,7 @@ Javier Domingo Cansino
|
|||
John Towler
|
||||
Joshua Bronson
|
||||
Jurko Gospodnetić
|
||||
Justyna Janczyszyn
|
||||
Katarzyna Jachim
|
||||
Kale Kundert
|
||||
Kevin Cox
|
||||
|
|
|
@ -149,7 +149,6 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
* Allow passing a custom debugger class (e.g. ``--pdbcls=IPython.core.debugger:Pdb``).
|
||||
Thanks to `@anntzer`_ for the PR.
|
||||
|
||||
|
||||
*
|
||||
|
||||
*
|
||||
|
@ -237,6 +236,9 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
|
||||
* ``optparse`` backward compatibility supports float/complex types (`#457`_).
|
||||
|
||||
* Better message in case of not using parametrized variable (see `#1539`_).
|
||||
Thanks to `@tramwaj29`_ for the PR.
|
||||
|
||||
*
|
||||
|
||||
*
|
||||
|
@ -318,6 +320,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
.. _#1664: https://github.com/pytest-dev/pytest/pull/1664
|
||||
.. _#1684: https://github.com/pytest-dev/pytest/pull/1684
|
||||
.. _#1723: https://github.com/pytest-dev/pytest/pull/1723
|
||||
.. _#1539: https://github.com/pytest-dev/pytest/issues/1539
|
||||
.. _#1749: https://github.com/pytest-dev/pytest/issues/1749
|
||||
|
||||
.. _@DRMacIver: https://github.com/DRMacIver
|
||||
|
@ -351,6 +354,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
.. _@tareqalayan: https://github.com/tareqalayan
|
||||
.. _@taschini: https://github.com/taschini
|
||||
.. _@txomon: https://github.com/txomon
|
||||
.. _@tramwaj29: https://github.com/tramwaj29
|
||||
|
||||
2.9.2
|
||||
=====
|
||||
|
|
|
@ -801,7 +801,13 @@ class Metafunc(fixtures.FuncargnamesCompatAttr):
|
|||
valtypes = {}
|
||||
for arg in argnames:
|
||||
if arg not in self.fixturenames:
|
||||
raise ValueError("%r uses no fixture %r" %(self.function, arg))
|
||||
if isinstance(indirect, (tuple, list)):
|
||||
name = 'fixture' if arg in indirect else 'argument'
|
||||
else:
|
||||
name = 'fixture' if indirect else 'argument'
|
||||
raise ValueError(
|
||||
"%r uses no %s %r" % (
|
||||
self.function, name, arg))
|
||||
|
||||
if indirect is True:
|
||||
valtypes = dict.fromkeys(argnames, "params")
|
||||
|
|
|
@ -394,7 +394,7 @@ class TestMetafunc:
|
|||
""")
|
||||
result = testdir.runpytest("--collect-only")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*uses no fixture 'y'*",
|
||||
"*uses no argument 'y'*",
|
||||
])
|
||||
|
||||
@pytest.mark.issue714
|
||||
|
@ -417,8 +417,42 @@ class TestMetafunc:
|
|||
"*uses no fixture 'y'*",
|
||||
])
|
||||
|
||||
@pytest.mark.issue714
|
||||
def test_parametrize_indirect_uses_no_fixture_error_indirect_string(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
@pytest.fixture(scope='function')
|
||||
def x(request):
|
||||
return request.param * 3
|
||||
|
||||
@pytest.mark.parametrize('x, y', [('a', 'b')], indirect='y')
|
||||
def test_simple(x):
|
||||
assert len(x) == 3
|
||||
""")
|
||||
result = testdir.runpytest("--collect-only")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*uses no fixture 'y'*",
|
||||
])
|
||||
|
||||
@pytest.mark.issue714
|
||||
def test_parametrize_indirect_uses_no_fixture_error_indirect_list(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
@pytest.fixture(scope='function')
|
||||
def x(request):
|
||||
return request.param * 3
|
||||
|
||||
@pytest.mark.parametrize('x, y', [('a', 'b')], indirect=['y'])
|
||||
def test_simple(x):
|
||||
assert len(x) == 3
|
||||
""")
|
||||
result = testdir.runpytest("--collect-only")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*uses no fixture 'y'*",
|
||||
])
|
||||
|
||||
@pytest.mark.issue714
|
||||
def test_parametrize_argument_not_in_indirect_list(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
@pytest.fixture(scope='function')
|
||||
|
@ -431,7 +465,7 @@ class TestMetafunc:
|
|||
""")
|
||||
result = testdir.runpytest("--collect-only")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*uses no fixture 'y'*",
|
||||
"*uses no argument 'y'*",
|
||||
])
|
||||
|
||||
def test_addcalls_and_parametrize_indirect(self):
|
||||
|
|
Loading…
Reference in New Issue