added indicative error when parametrizing an argument with a default value

This commit is contained in:
Brian Maissy
2018-04-04 19:44:01 +03:00
parent 36f6687b70
commit 857098fe0f
4 changed files with 33 additions and 7 deletions

View File

@@ -616,6 +616,19 @@ class TestMetafunc(object):
"*uses no argument 'y'*",
])
def test_parametrize_gives_indicative_error_on_function_with_default_argument(self, testdir):
testdir.makepyfile("""
import pytest
@pytest.mark.parametrize('x, y', [('a', 'b')])
def test_simple(x, y=1):
assert len(x) == 1
""")
result = testdir.runpytest("--collect-only")
result.stdout.fnmatch_lines([
"*already takes an argument 'y' with a default value",
])
def test_addcalls_and_parametrize_indirect(self):
def func(x, y):
pass