From bbf82ce8a1db9a2a0655a76c443891441b35d757 Mon Sep 17 00:00:00 2001 From: ArtyomSimitian Date: Tue, 3 Nov 2026 14:53:36 -0800 Subject: [PATCH 1/2] gh-156376: Fix test_environ_path_cwd when NoDefaultCurrentDirectoryInExePath is set --- Lib/test/test_shutil.py | 4 +++- .../next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index c0b48ea306b71ed..783fe1868249148 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -2729,7 +2729,9 @@ def test_environ_path_cwd(self): self.assertIsNone(rv) # look in current directory - with os_helper.change_cwd(self.dir): + with os_helper.change_cwd(self.dir), \ + unittest.mock.patch('shutil._win_path_needs_curdir', + return_value=True): rv = shutil.which(self.file) self.assertEqual(rv, expected_cwd) diff --git a/Misc/NEWS.d/next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst b/Misc/NEWS.d/next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst new file mode 100644 index 000000000000000..5d60405e9baba22 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst @@ -0,0 +1,3 @@ +Fix ``test_shutil.test_environ_path_cwd`` on Windows, which relied on the +user's ``NoDefaultCurrentDirectoryInExePath`` environment setting and was +therefore non-deterministic. \ No newline at end of file From df8a234806854a1814c2bc27d0695691bf065b6c Mon Sep 17 00:00:00 2001 From: ArtyomSimitian Date: Tue, 3 Nov 2026 15:03:42 -0800 Subject: [PATCH 2/2] Add missing final newline to NEWS entry --- .../next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst b/Misc/NEWS.d/next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst index 5d60405e9baba22..73bb4f482df29cb 100644 --- a/Misc/NEWS.d/next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst +++ b/Misc/NEWS.d/next/Tests/2026-11-03-22-45-00.gh-issue-156376.Wq7rKe.rst @@ -1,3 +1,3 @@ Fix ``test_shutil.test_environ_path_cwd`` on Windows, which relied on the user's ``NoDefaultCurrentDirectoryInExePath`` environment setting and was -therefore non-deterministic. \ No newline at end of file +therefore non-deterministic.