Skip to content

tests: assert the PermissionError filename as OSError renders it (TEST-WIN-PERMERR-REPR) - #1425

Merged
Andretuta merged 1 commit into
ProjectLeonida:mainfrom
thiefyzheng:fix/test-permerr-repr
Nov 27, 2026
Merged

Andretuta merged 1 commit into
ProjectLeonida:mainfrom
thiefyzheng:fix/test-permerr-repr

Conversation

@thiefyzheng

Copy link
Copy Markdown
Contributor

What

One line in each of three test files: self.assertIn(blocked, err.getvalue()) → self.assertIn(repr(blocked), err.getvalue()).

Why

The finding is @GTAVIB4GTAVI's (coordination issue #14, 23:34:10Z): the three unreadable-directory tests mock os.walk's onerror with PermissionError(13, "Permission denied", blocked) and assert the path appears in the tool's stderr. The tools print ERROR: {e} — tools/world_names.py:671, tools/bink_names.py:459, tools/opus_tags.py:278 — and str(OSError) renders .filename with repr(): quoted, backslashes doubled. On Windows each of the three assertions failed on the actual repr'd line; on Linux the paths contain no backslashes, so the files pass there and the defect was invisible to the Linux CI. The assertion now compares repr(blocked) — the exact rendering under test — which passes on both platforms.

This is the finding's first suggested form ("compare the value against the error's rendered filename"). Its alternative — the tools printing the path unquoted, as tools/awc_manifest.py:268 and tools/bink_index.py:438 already do — would change three tools' stderr, and is a tools/ change rather than this one; happy to do that instead if a reviewer prefers the tool-side behavior.

Corroboration: sibling tests with the same assertion shape pass on Windows because their tools print the path unquoted (test_awc_manifest.py:312 → tools/awc_manifest.py:268; test_bink_index.py:339), and test_awc_opus.py:435-436 asserts only the basename and strerror, which the repr'd line contains — so exactly these three tests fail, as the finding said.

What I ran

Windows 11 (Python 3.12.10), before (hub main 507029d1e): one named failure per file, at the finding's exact lines — test_world_names.py:49 (1 of 31), test_bink_names.py:340 (1 of 36), test_opus_tags.py:337 (1 of 28); each assertion shows the plain path missing from the repr'd stderr line (quoted in the claim thread). After: all three files OK — 31/36/28 tests. Linux (CPython 3.13): before and after, all three files OK with identical counts, so the fix does not change Linux behavior. The patch was applied byte-identically on both platforms; scripts/check_no_game_data.py clean.

Not run

Not run under the repo's full CI suites (workflows will cover these files on both platforms); the tool-side alternative was deliberately not implemented.

AI-assisted: a pi coding agent operated by the repo contributor ran the Windows reproduction and both-platform verification; the finding is @GTAVIB4GTAVI's.

…T-WIN-PERMERR-REPR)

Three unreadable-directory tests compared the plain path against the
captured stderr, but the tools print str(exc), whose .filename is rendered
with repr(): quoted, backslashes doubled. On Windows each file failed that
one assertion; on Linux the path never contains backslashes so they passed.
The assertions now compare repr(blocked), the exact rendering under test.

The finding is GTAVIB4GTAVI's (coordination issue ProjectLeonida#14, 23:34:10Z).

AI-assisted.
@whoalin1

Copy link
Copy Markdown
Contributor

Independent confirmation on native Windows 11 (Python 3.14): clean origin/main 3ff2a2adc fails exactly these three tests — tests/test_bink_names.py::TestCli::test_unreadable_mount_directory_preserves_the_report, tests/test_world_names.py::ManifestEnumerationTest::test_an_unreadable_subtree_does_not_replace_the_dictionary, tests/test_opus_tags.py::TestFolder::test_cli_reports_incomplete_directory_discovery. Root cause matches the PR description: str(PermissionError) renders the filename with repr-escaped backslashes on Windows, so the single-backslash path never matches stderr. This means the windows-latest CI check leg has very likely been red since ~Nov 23. Verified standalone via py -3.14 -I tests/test_bink_names.py → FAILED (failures=1). The repr(blocked) assertion is the right fix (asserting the escaped form keeps coverage on both platforms).

@Mby159

Mby159 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent check on native Windows 11, because the failure this starts from comes from repr() doubling the backslashes in a Windows path.

This PR and #128 are the two sides of the same item, and they cannot both land. #128 changes the three tools; this PR changes the three tests. Whichever lands second makes the three files fail again. #128 is open (a draft carried over from the old repository), and this PR's description offers the tool-side option but does not reference #128.

Measured on current main (3f81d46ac), each tree a clean checkout plus the PR diff applied with git apply (#128 @ 82bdc54f, #1425 @ 04b6b2ee; Windows 11 x64 10.0.29712, CPython 3.13.17, standard library only, no game files, no GPU):

tree tests/test_world_names.py tests/test_bink_names.py tests/test_opus_tags.py
main 31 run, 1 failure 36 run, 1 failure 28 run, 1 failure
main + #128 31 run, OK 36 run, OK 28 run, OK
main + #1425 31 run, OK 36 run, OK 28 run, OK
main + #1425 + #128 31 run, 1 failure 36 run, 1 failure 28 run, 1 failure

The three failures on main are the three this PR targets: str(PermissionError) renders the filename with repr(), so the path in the message has doubled backslashes and the plain path is not in the text. With both patches applied the failure is the same assertion in the opposite direction - the message holds the plain path, so repr(path) is no longer in it.

Two notes for the reviewer:

I ran the three files named above, and the 20 standard-library test files under tests/ whose source mentions world_names, bink_names, opus_tags, awc_manifest, awc_markers or bink_index (20 run, 0 failures; that set includes the three files above) on the tree with #128 applied. Not run: Linux, the CI workflows, the translator suite, and a full pass over all 535 standard-library test files.

AI-assisted.

@DeadlyChirp

Copy link
Copy Markdown

Tested on Windows 11, Python 3.12.10. I merged 04b6b2e onto upstream main (merge commit f173f1485).

test main this PR
python -I tests/test_bink_names.py FAILED (failures=1) OK
python -I tests/test_opus_tags.py FAILED (failures=1) OK
python -I tests/test_world_names.py FAILED (failures=1) OK

On main, each test fails the same way: the expected path is not found in [Errno 13] permission denied: 'C:\Users\...\blocked', because OSError prints the filename as a repr with doubled backslashes.

Note for whoever merges: #128 and #1792 take the other route and change the tools to print the plain path. If one of those lands, the assertions here may need to match the new output.

(AI-assisted test run; output checked by hand.)

@thiefyzheng

Copy link
Copy Markdown
Contributor Author

Noting for whoever merges, per @Mby159 and @DeadlyChirp: this PR (test side) and #128 / #1792 (tool side, print the plain path) fix the same three Windows failures and cannot both land, because whichever lands second makes the three files fail again. Either is fine with us. If #128 or #1792 is chosen, close this PR; if this one is chosen, #128 should be closed or rebased to drop the three tool changes. Maintainer's call.

AI-assisted (Claude Code).

@OguzSoykan

Copy link
Copy Markdown

Verified on native Windows at head 04b6b2ee4: test_bink_names.py, test_opus_tags.py and test_world_names.py fail on main (the expected path is the plain one, the message carries the repr with doubled backslashes) and pass here. The tool-side fixes #128 and #1792 also make all three pass on this machine; as noted in the coordination issue, the test-side and tool-side fixes go in opposite directions, so only one side should be merged.

Native Windows 10 Pro 19045, CPython 3.12, py -3.12 -I, checkout under a non-ASCII profile path (C:\Users\Oğuz\..., TEMP is the 8.3 alias C:\Users\OUZ~1\...). No game files.

AI-assisted (Claude Code).

@wavehs

wavehs commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

The tool-side alternative you offered already exists as #1792 (Ch1mpleo, claimed as OLD-9861, rebased onto current main): it makes all three tools print {e.filename or <arg>}: {e.strerror or e}, so the path is plain and unquoted, like awc_manifest.py:268 and bink_index.py:438 that you cite as corroboration.

The two cannot both land: this PR asserts the repr rendering, and #1792 changes that rendering to the plain path, so whichever lands second must rewrite these three assertions.

I would take #1792:

  • The doubled, quoted path is what the player or contributor sees in the tool's error, not just a test inconvenience; C:\\Users\\... in a message is the defect.
  • It fixes the same three Windows failures without teaching the tests to expect the broken spelling.
  • I verified tools: print the plain path, not a repr'd one, in OSError messages (OLD-9861) #1792 on main f107ae044: with a backslash in TMPDIR the three files fail on unmodified main and are OK with that diff (36/28/31 tests).

Your reproduction and the before/after numbers are solid, and the finding is real; this is only about which side of the contract changes. If the coordinator prefers the test-side change, then #1792 needs a rebase afterwards — but my vote is to close this one in favour of #1792.

AI-assisted (review only).

@Andretuta

Copy link
Copy Markdown
Collaborator

I reproduced the path assertion failure in all three files on native Windows with CPython 3.13.14 and no NumPy at main d1dff7949. The reported paths had escaped backslashes, and the assertions expected the raw paths. With 04b6b2ee4 in the local CI integration, test_bink_names.py passed 36/36, test_opus_tags.py 28/28 and test_world_names.py 31/31 under #2193's two-worker runner.

AI-assisted testing.

@Andretuta
Andretuta merged commit 4c553de into ProjectLeonida:main Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants