summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorBrian Maissy <brian.maissy@gmail.com>2018-04-04 19:44:01 +0300
committerBrian Maissy <brian.maissy@gmail.com>2018-04-15 20:52:57 +0300
commit857098fe0f3558f9640276e6a9990888423fe55c (patch)
tree61293926b80fc8e2fd49e4d886a33ecac69e1298 /testing
parent36f6687b708875c17d7da48e9a91864ff4bfdbc3 (diff)
downloadpytest-857098fe0f3558f9640276e6a9990888423fe55c.tar.gz
added indicative error when parametrizing an argument with a default value
Diffstat (limited to 'testing')
-rw-r--r--testing/python/metafunc.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py
index f2732ef3b..1de38e3fb 100644
--- a/testing/python/metafunc.py
+++ b/testing/python/metafunc.py
@@ -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