Repository navigation
Make test_compileall's path-like output checks effective - #161775
Open
andresdelfino wants to merge 1 commit into
Open
andresdelfino wants to merge 1 commit into
andresdelfino wants to merge 1 commit into
Conversation
The regex `[^WindowsPath|PosixPath]` is a negated character class: it only checks that the first character after "Compiling " / "Listing " is not one of those letters. Since the tests switched from pathlib.Path to FakePath (pythongh-119064), whose repr starts with "<", the regex matches even if compileall prints the repr of the path-like object instead of the path. Compare against the exact expected line instead, using !r so the quoting and Windows backslash escaping match what compileall prints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_compile_file_pathlikeandtest_compile_dir_pathlikecheck the output with:[^WindowsPath|PosixPath]is a negated character class, not "anything butWindowsPathorPosixPath": it only checks that the first character afterCompiling/Listingisn't one ofW i n d o w s P a t h | x. That worked when the tests usedpathlib.Path, but since gh-119064 switched them toFakePath, whose repr is<FakePath '...'>, the regex matches no matter what is printed.With a modified
compileallthat prints the path-like object's repr, both tests still pass:This PR compares against the exact expected line instead, which is what the tests did before d8e9713. Using
!rmatches the quoting and Windows backslash escapingcompileallprints, which is why the regex was introduced. With this change, the modifiedcompileallmakes both tests fail, and the unmodified one passes.🤖 Generated with Claude Code