From 58fc40427f2928190c8d273ceff2121b738e768b Mon Sep 17 00:00:00 2001 From: Roel Delos Reyes Date: Thu, 26 Jun 2025 01:26:58 +0800 Subject: [PATCH] Fixed #36479 -- Improved how FileNotFoundError is triggered in code formatter tests. Ensured the test for formatter subprocess FileNotFoundError doesn't rely on platform-specific behavior, improving reliability on macOS and other systems by consistently using pathlib to build test paths. --- tests/user_commands/tests.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py index acc338685e..4b03f54564 100644 --- a/tests/user_commands/tests.py +++ b/tests/user_commands/tests.py @@ -565,11 +565,15 @@ class UtilsTests(SimpleTestCase): self.assertEqual(normalize_path_patterns(["foo/bar/*", "bar/*/"]), expected) def test_run_formatters_handles_oserror_for_black_path(self): + test_files_path = Path(__file__).parent / "test_files" cases = [ - (FileNotFoundError, "nonexistent"), + ( + FileNotFoundError, + str(test_files_path / "nonexistent"), + ), ( OSError if sys.platform == "win32" else PermissionError, - str(Path(__file__).parent / "test_files" / "black"), + str(test_files_path / "black"), ), ] for exception, location in cases: