Improve check for misspelling of parametrize

- there is no need to do this with `--strict-markers`
- it can be done when looking up marks, instead of for every generated
  test
This commit is contained in:
Daniel Hahler
2019-11-19 15:58:46 +01:00
parent 89eeefbbaf
commit 4ad61cbcf6
4 changed files with 25 additions and 25 deletions

View File

@@ -120,17 +120,7 @@ def pytest_cmdline_main(config):
return 0
def _validate_parametrize_spelling(metafunc):
"""Raise a specific error for common misspellings of "parametrize"."""
for mark_name in ["parameterize", "parametrise", "parameterise"]:
if metafunc.definition.get_closest_marker(mark_name):
msg = "{0} has '{1}' mark, spelling should be 'parametrize'"
fail(msg.format(metafunc.function.__name__, mark_name), pytrace=False)
def pytest_generate_tests(metafunc):
_validate_parametrize_spelling(metafunc)
for marker in metafunc.definition.iter_markers(name="parametrize"):
metafunc.parametrize(*marker.args, **marker.kwargs)