Skip to content

Tests: Unset PYTEST_XDIST_AUTO_NUM_WORKERS when the behavior without the envvar is asserted #870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/870.trivial
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make the tests pass even when ``$PYTEST_XDIST_AUTO_NUM_WORKERS`` is set.
7 changes: 7 additions & 0 deletions testing/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def test_auto_detect_cpus(
) -> None:
from xdist.plugin import pytest_cmdline_main as check_options

monkeypatch.delenv("PYTEST_XDIST_AUTO_NUM_WORKERS", raising=False)

with suppress(ImportError):
import psutil

Expand Down Expand Up @@ -101,6 +103,7 @@ def test_auto_detect_cpus_psutil(

psutil = pytest.importorskip("psutil")

monkeypatch.delenv("PYTEST_XDIST_AUTO_NUM_WORKERS", raising=False)
monkeypatch.setattr(psutil, "cpu_count", lambda logical=True: 84 if logical else 42)

config = pytester.parseconfigure("-nauto")
Expand All @@ -117,6 +120,8 @@ def test_auto_detect_cpus_os(
) -> None:
from xdist.plugin import pytest_cmdline_main as check_options

monkeypatch.delenv("PYTEST_XDIST_AUTO_NUM_WORKERS", raising=False)

config = pytester.parseconfigure("-nauto")
check_options(config)
assert config.getoption("numprocesses") == 3
Expand Down Expand Up @@ -178,6 +183,8 @@ def test_hook_auto_num_workers_none(
# but we document it so let's test it.
from xdist.plugin import pytest_cmdline_main as check_options

monkeypatch.delenv("PYTEST_XDIST_AUTO_NUM_WORKERS", raising=False)

pytester.makeconftest(
"""
def pytest_xdist_auto_num_workers():
Expand Down