Repository navigation
Fix test_import assertions that never compared against the expected value - #161831
Open
andresdelfino wants to merge 1 commit into
Open
andresdelfino wants to merge 1 commit into
andresdelfino wants to merge 1 commit into
Conversation
…alue test_pyinit_function_raises_exception called assertIsNotNone() with the expected value as the second argument, which is the failure message, so the exception's type name and message were never checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andresdelfino
requested review from
FFY00,
brettcannon,
ericsnowcurrently,
ncoghlan and
warsaw
as code owners
November 11, 2026 21:43
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_pyinit_function_raises_exceptionpassed the expected value as the second argument ofassertIsNotNone(), which is the failure message:So the test only checked that the type name and message were not
None, and never compared them with the intended values. This switches both toassertEqual(). The expected message matches theImportErrorraised inPython/import.c(added in gh-144601).Follow-up to #161774, which fixed the same mistake with
assertTrue(). It was found the same way, by walking the AST of every tracked.pyfile forassert*calls whosemsgargument isn't a string, then reviewing each hit by hand. The other hits either pass useful context (inputs, process output, etc.) or are harmless leftovers such asassertIsNone(x, None), so they are left alone.Test-only change, so this should be fine for
skip issue/skip news. Tested locally on Linux.🤖 Generated with Claude Code