diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 18e0e3c64..b4b7bffa6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -27,7 +27,8 @@ whether to filter the traceback based on the ``ExceptionInfo`` object passed to it. -* +* New ``pytest_make_parametrize_id`` hook. + Thanks `@palaviv`_ for the PR. **Changes** diff --git a/_pytest/hookspec.py b/_pytest/hookspec.py index 5d70ea1c3..b5125ffdb 100644 --- a/_pytest/hookspec.py +++ b/_pytest/hookspec.py @@ -133,12 +133,6 @@ def pytest_deselected(items): def pytest_make_collect_report(collector): """ perform ``collector.collect()`` and return a CollectReport. """ -@hookspec(firstresult=True) -def pytest_make_parametrize_id(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``. - """ - # ------------------------------------------------------------------------- # Python test function related hooks # ------------------------------------------------------------------------- @@ -162,6 +156,12 @@ def pytest_pyfunc_call(pyfuncitem): def pytest_generate_tests(metafunc): """ generate (multiple) parametrized calls to a test function.""" +@hookspec(firstresult=True) +def pytest_make_parametrize_id(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``. + """ + # ------------------------------------------------------------------------- # generic runtest related hooks # ------------------------------------------------------------------------- diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index cc346aaa8..38d47bf6d 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -470,6 +470,7 @@ you can use the following hook: .. autofunction:: pytest_pycollect_makeitem .. autofunction:: pytest_generate_tests +.. autofunction:: pytest_make_parametrize_id After collection is complete, you can modify the order of items, delete or otherwise amend the test items: