From 9733127951b1737e54eb9902a0835891f1dbee56 Mon Sep 17 00:00:00 2001 From: palaviv Date: Tue, 26 Apr 2016 10:23:57 +0300 Subject: [PATCH] pytest_make_parametrize_id receive config object --- _pytest/hookspec.py | 2 +- _pytest/python.py | 4 ++-- testing/python/metafunc.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_pytest/hookspec.py b/_pytest/hookspec.py index b5125ffdb..424ee2069 100644 --- a/_pytest/hookspec.py +++ b/_pytest/hookspec.py @@ -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``. """ diff --git a/_pytest/python.py b/_pytest/python.py index aa80c8640..9a97e7236 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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 diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 28b3e0d64..6ce6cb751 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -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("""