Repository navigation
tests: assert the PermissionError filename as OSError renders it (TEST-WIN-PERMERR-REPR) - #1425
Conversation
…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.
|
Independent confirmation on native Windows 11 (Python 3.14): clean |
|
Independent check on native Windows 11, because the failure this starts from comes from 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
The three failures on Two notes for the reviewer:
I ran the three files named above, and the 20 standard-library test files under AI-assisted. |
|
Tested on Windows 11, Python 3.12.10. I merged 04b6b2e onto upstream main (merge commit f173f1485).
On main, each test fails the same way: the expected path is not found in 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.) |
|
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). |
|
Verified on native Windows at head Native Windows 10 Pro 19045, CPython 3.12, AI-assisted (Claude Code). |
|
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 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:
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). |
|
I reproduced the path assertion failure in all three files on native Windows with CPython 3.13.14 and no NumPy at AI-assisted testing. |
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'sonerrorwithPermissionError(13, "Permission denied", blocked)and assert the path appears in the tool's stderr. The tools printERROR: {e}—tools/world_names.py:671,tools/bink_names.py:459,tools/opus_tags.py:278— andstr(OSError)renders.filenamewithrepr(): 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 comparesrepr(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:268andtools/bink_index.py:438already 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), andtest_awc_opus.py:435-436asserts only the basename andstrerror, 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.pyclean.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.