From 54a2abdc5fb537e7780bbc0a325f552baed59c2d Mon Sep 17 00:00:00 2001 From: wavehs <156133648+wavehs@users.noreply.github.com> Date: Tue, 24 Nov 2026 04:12:13 +0200 Subject: [PATCH] tests: match the path as the error message prints it on Windows OSError.__str__ formats the filename with %r, so on Windows every backslash is doubled: the message holds C:\\Users\\... where the tempfile path is C:\Users\.... three tests asserted the raw path with assertIn and failed on Windows only ('not found in "ERROR: [Errno 13] Permission denied: C:\\\\Users..."'), which is how the check job keeps three files red. --- tests/test_bink_names.py | 4 +++- tests/test_opus_tags.py | 4 +++- tests/test_world_names.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_bink_names.py b/tests/test_bink_names.py index 62790e08f1..63c1ca3c3f 100644 --- a/tests/test_bink_names.py +++ b/tests/test_bink_names.py @@ -337,7 +337,9 @@ def walk(path, onerror=None): with mock.patch.object(names_mod.os, "walk", walk), \ contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()) as err: self.assertEqual(names_mod.main([source, "--mount", mount, "--out", report]), 1) - self.assertIn(blocked, err.getvalue()) + # OSError's own message prints the filename with %r, so on Windows every backslash is doubled: + # compare the repr, which is what the tool prints, not the raw path. + self.assertIn(repr(blocked), err.getvalue()) with open(report, "rb") as f: self.assertEqual(f.read(), b"previous report") diff --git a/tests/test_opus_tags.py b/tests/test_opus_tags.py index 9648cd388e..7c6242bc53 100644 --- a/tests/test_opus_tags.py +++ b/tests/test_opus_tags.py @@ -334,7 +334,9 @@ def walk(path, onerror=None): with mock.patch.object(T.os, "walk", walk), contextlib.redirect_stderr(io.StringIO()) as err: self.assertEqual(T.main([root, "--names", names, "--dry-run"]), 2) - self.assertIn(blocked, err.getvalue()) + # OSError's own message prints the filename with %r, so on Windows every backslash is doubled: + # compare the repr, which is what the tool prints, not the raw path. + self.assertIn(repr(blocked), err.getvalue()) def test_cli(self): r = subprocess.run([sys.executable, "-I", TOOL, self.opus, "--names", self.names, "--source", "story", diff --git a/tests/test_world_names.py b/tests/test_world_names.py index ceb2dc92b3..2967c0217e 100644 --- a/tests/test_world_names.py +++ b/tests/test_world_names.py @@ -46,7 +46,9 @@ def walk(root, onerror=None): with mock.patch.object(WN.os, "walk", walk), contextlib.redirect_stderr(io.StringIO()) as err, \ contextlib.redirect_stdout(io.StringIO()): self.assertEqual(WN.main(["build", "--manifest", manifests, "--names", names, "--out", output]), 1) - self.assertIn(blocked, err.getvalue()) + # OSError's own message prints the filename with %r, so on Windows every backslash is doubled: + # compare the repr, which is what the tool prints, not the raw path. + self.assertIn(repr(blocked), err.getvalue()) with open(output, "rb") as f: self.assertEqual(f.read(), b"existing dictionary")