From c7c7f9ef5b1ddbde134f11f33cffcb279b5ca160 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 24 Sep 2021 08:17:11 -0300 Subject: [PATCH] Use modern options configurations for hooks Noticed while reviewing https://github.com/pytest-dev/pytest/pull/9118 --- changelog/708.trivial.rst | 1 + src/xdist/newhooks.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 changelog/708.trivial.rst diff --git a/changelog/708.trivial.rst b/changelog/708.trivial.rst new file mode 100644 index 00000000..38b41769 --- /dev/null +++ b/changelog/708.trivial.rst @@ -0,0 +1 @@ +Use ``@pytest.hookspec`` decorator to declare hook options in ``newhooks.py`` to avoid warnings in ``pytest 7.0``. diff --git a/src/xdist/newhooks.py b/src/xdist/newhooks.py index d2482aff..f9ac6b4d 100644 --- a/src/xdist/newhooks.py +++ b/src/xdist/newhooks.py @@ -30,7 +30,7 @@ def pytest_xdist_rsyncfinish(source, gateways): """called after rsyncing a directory to remote gateways takes place.""" -@pytest.mark.firstresult +@pytest.hookspec(firstresult=True) def pytest_xdist_getremotemodule(): """called when creating remote node""" @@ -51,12 +51,12 @@ def pytest_xdist_node_collection_finished(node, ids): """called by the controller node when a worker node finishes collecting.""" -@pytest.mark.firstresult +@pytest.hookspec(firstresult=True) def pytest_xdist_make_scheduler(config, log): """return a node scheduler implementation""" -@pytest.mark.firstresult +@pytest.hookspec(firstresult=True) def pytest_xdist_auto_num_workers(config): """ Return the number of workers to spawn when ``--numprocesses=auto`` is given in the @@ -66,7 +66,7 @@ def pytest_xdist_auto_num_workers(config): """ -@pytest.mark.firstresult +@pytest.hookspec(firstresult=True) def pytest_handlecrashitem(crashitem, report, sched): """ Handle a crashitem, modifying the report if necessary.