diff --git a/_pytest/python.py b/_pytest/python.py index 318038771..e12664378 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -142,6 +142,13 @@ def pytest_cmdline_main(config): def pytest_generate_tests(metafunc): + try: + # this misspelling is common - raise a specific error to alert the user + markers = metafunc.function.parameterize + msg = "{} has mark 'parameterize', spelling should be 'parametrize'" + raise ValueError(msg.format(metafunc.function.__name__)) + except AttributeError: + pass try: markers = metafunc.function.parametrize except AttributeError: diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 651e3846e..c1a573a47 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -692,6 +692,21 @@ class TestMetafuncFunctional: reprec = testdir.inline_run() reprec.assertoutcome(passed=4) + @pytest.mark.issue463 + def test_parameterize_misspelling(self, testdir): + testdir.makepyfile(""" + import pytest + + @pytest.mark.parameterize("x", range(2)) + def test_foo(x): + pass + """) + reprec = testdir.inline_run('--collectonly') + failures = reprec.getfailures() + assert len(failures) == 1 + expectederror = "ValueError: test_foo has mark 'parameterize', spelling should be 'parametrize'" + assert expectederror in failures[0].longrepr.reprcrash.message + class TestMarkersWithParametrization: pytestmark = pytest.mark.issue308