From 8fd1bfd182e87f46e2c2ff6dbb43c0cd43d0cc00 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Tue, 17 Jan 2023 18:02:32 +0100
Subject: [PATCH] Tests: Unset PYTEST_XDIST_AUTO_NUM_WORKERS when the behavior
 without the envvar is asserted

---
 changelog/870.trivial  | 1 +
 testing/test_plugin.py | 7 +++++++
 2 files changed, 8 insertions(+)
 create mode 100644 changelog/870.trivial

diff --git a/changelog/870.trivial b/changelog/870.trivial
new file mode 100644
index 00000000..5a1bd3d0
--- /dev/null
+++ b/changelog/870.trivial
@@ -0,0 +1 @@
+Make the tests pass even when ``$PYTEST_XDIST_AUTO_NUM_WORKERS`` is set.
diff --git a/testing/test_plugin.py b/testing/test_plugin.py
index c17a2734..f42f3cc7 100644
--- a/testing/test_plugin.py
+++ b/testing/test_plugin.py
@@ -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
 
@@ -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")
@@ -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
@@ -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():
