pytest_make_parametrize_id receive config object

This commit is contained in:
palaviv 2016-04-26 10:23:57 +03:00
parent 53429ed8b8
commit 9733127951
3 changed files with 4 additions and 4 deletions

View File

@ -157,7 +157,7 @@ def pytest_generate_tests(metafunc):
""" generate (multiple) parametrized calls to a test function."""
@hookspec(firstresult=True)
def pytest_make_parametrize_id(val):
def pytest_make_parametrize_id(config, val):
"""Return a user-friendly string representation of the given ``val`` that will be used
by @pytest.mark.parametrize calls. Return None if the hook doesn't know about ``val``.
"""

View File

@ -342,7 +342,7 @@ def pytest_pycollect_makeitem(collector, name, obj):
res = list(collector._genfunctions(name, obj))
outcome.force_result(res)
def pytest_make_parametrize_id(val):
def pytest_make_parametrize_id(config, val):
return None
def is_generator(func):
@ -1143,7 +1143,7 @@ def _idval(val, argname, idx, idfn, config=None):
pass
if config:
hook_id = config.hook.pytest_make_parametrize_id(val=val)
hook_id = config.hook.pytest_make_parametrize_id(config=config, val=val)
if hook_id:
return hook_id

View File

@ -1159,7 +1159,7 @@ class TestMarkersWithParametrization:
def test_pytest_make_parametrize_id(self, testdir):
testdir.makeconftest("""
def pytest_make_parametrize_id(val):
def pytest_make_parametrize_id(config, val):
return str(val * 2)
""")
testdir.makepyfile("""