Raise a ValueError early if user misspells 'parametrize' as 'parameterize'. --HG-- branch : issue463
This commit is contained in:
parent
cf7bb70809
commit
ac17f20d98
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue