From 8b0856a986e5b4ee665fcf551d6d3bbaa7a626fa Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 22 Oct 2022 10:24:20 -0300 Subject: [PATCH] Deprecate looponfail plugin Fix #826 --- changelog/826.deprecation.rst | 0 pyproject.toml | 7 ++++++- src/xdist/looponfail.py | 5 ++++- src/xdist/plugin.py | 11 ++++++++--- testing/acceptance_test.py | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 changelog/826.deprecation.rst diff --git a/changelog/826.deprecation.rst b/changelog/826.deprecation.rst new file mode 100644 index 00000000..e69de29b diff --git a/pyproject.toml b/pyproject.toml index 72a7f7d7..1a462ccd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,12 @@ template = "changelog/_template.rst" [[tool.towncrier.type]] directory = "removal" - name = "Deprecations and Removals" + name = "Removals" + showcontent = true + + [[tool.towncrier.type]] + directory = "deprecation" + name = "Deprecations" showcontent = true [[tool.towncrier.type]] diff --git a/src/xdist/looponfail.py b/src/xdist/looponfail.py index 4b4f4061..7f3ea92b 100644 --- a/src/xdist/looponfail.py +++ b/src/xdist/looponfail.py @@ -46,7 +46,10 @@ def pytest_cmdline_main(config): def looponfail_main(config: pytest.Config) -> None: remotecontrol = RemoteControl(config) - rootdirs = [Path(root) for root in config.getini("looponfailroots")] + config_roots = config.getini("looponfailroots") + if not config_roots: + config_roots = [Path.cwd()] + rootdirs = [Path(root) for root in config_roots] statrecorder = StatRecorder(rootdirs) try: while 1: diff --git a/src/xdist/plugin.py b/src/xdist/plugin.py index f530b361..92dc22e4 100644 --- a/src/xdist/plugin.py +++ b/src/xdist/plugin.py @@ -1,7 +1,6 @@ import os import uuid import sys -from pathlib import Path import pytest @@ -158,8 +157,7 @@ def pytest_addoption(parser): parser.addini( "looponfailroots", type="paths" if PYTEST_GTE_7 else "pathlist", - help="directories to check for changes", - default=[Path.cwd()], + help="directories to check for changes. Default: current directory.", ) @@ -191,6 +189,13 @@ def pytest_configure(config): if tr: tr.showfspath = False + if config.getoption("looponfail", None) or config.getini("looponfailroots"): + warning = DeprecationWarning( + "The --looponfail command line argument and looponfailroots config variable are deprecated.\n" + "The loop-on-fail feature will be removed in pytest-xdist 4.0." + ) + config.issue_config_time_warning(warning, 2) + config_line = ( "xdist_group: specify group for tests should run in same session." "in relation to one another. " + "Provided by pytest-xdist." diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 94129f1d..792852d1 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -740,7 +740,7 @@ def test_ok(): pass """ ) - result = pytester.runpytest(p1, "-n1", "-p", "no:%s" % plugin) + result = pytester.runpytest(p1, "-n1", "-p", f"no:{plugin}") assert result.ret == 0 result.stdout.fnmatch_lines("*1 passed*")