From eb03b2cd5ee523d1ce1336794f45438cb92b1352 Mon Sep 17 00:00:00 2001 From: Kevin Deldycke Date: Sat, 28 Feb 2026 13:56:12 +0400 Subject: [PATCH] Fix pager test pollution for parallel execution Use pytest's ``tmp_path`` fixture instead of a shared ``Path(tempdir) / "pager_out.txt"`` path. The ``tempfile.tempdir`` module global defaults to ``None``, so ``Path(None)`` resolves to the current directory, causing all parallel workers to race on the same file. --- tests/test_utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 1b1575657c..f5da596337 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -9,8 +9,6 @@ from fractions import Fraction from functools import partial from io import StringIO -from pathlib import Path -from tempfile import tempdir from unittest.mock import patch import pytest @@ -379,7 +377,7 @@ def _test_simulate_keyboard_interrupt(file=None): ), ], ) -def test_echo_via_pager(monkeypatch, capfd, pager_cmd, test): +def test_echo_via_pager(monkeypatch, capfd, pager_cmd, test, tmp_path): monkeypatch.setitem(os.environ, "PAGER", pager_cmd) monkeypatch.setattr(click._termui_impl, "isatty", lambda x: True) @@ -391,8 +389,7 @@ def test_echo_via_pager(monkeypatch, capfd, pager_cmd, test): check_raise = pytest.raises(expected_error) if expected_error else nullcontext() - pager_out_tmp = Path(tempdir) / "pager_out.txt" - pager_out_tmp.unlink(missing_ok=True) + pager_out_tmp = tmp_path / "pager_out.txt" with pager_out_tmp.open("w") as f: force_subprocess_stdout = patch.object( subprocess,