Skip to content

Commit

Permalink
Factor out _validate_parametrize_spelling (#6221)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Nov 18, 2019
2 parents a2d4833 + 91dec8e commit b412661
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,17 @@ def pytest_cmdline_main(config):
return 0


def pytest_generate_tests(metafunc):
# those alternative spellings are common - raise a specific error to alert
# the user
alt_spellings = ["parameterize", "parametrise", "parameterise"]
for mark_name in alt_spellings:
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)

Expand Down

0 comments on commit b412661

Please sign in to comment.