test[next]: un-shadow the duplicate test_annotated_assign - #2871
Open
Anai-Guo wants to merge 1 commit into
Open
Conversation
test_single_static_assign.py defines test_annotated_assign twice at module level (L111 and L635) with different bodies, so pytest only ever collects the second one and the first never runs -- 30 test functions, 29 collected. L111 covers an annotated assignment that has a value (`a: int = 5`); L635 covers a bare annotation applying to the following assignment (`a: int` then `a = a + 1`), which is what its own inline comment says. Renames the second to test_annotation_applies_to_next_assign so both run. Both pass: 29 passed -> 30 passed.
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.
Problem
tests/next_tests/unit_tests/ffront_tests/ast_passes_tests/test_single_static_assign.pydefinestest_annotated_assigntwice at module level, with different bodies:L111 — an annotated assignment that carries a value:
asserting
a{SEP}0: int = 5, with the docstring "The name of type annotations should not be treated as an assignment target."L635 — a bare annotation applying to the next assignment:
asserting
a{SEP}0: int/a{SEP}0 = a + 1.The second binding shadows the first, so pytest only ever collects one of them. The file has 30
def test_at module level but collects 29:The L111 case — annotated assign with a value — is currently never exercised. It is a distinct case from its neighbour
test_empty_annotated_assign(L123), which covers a bare annotation between two assignments.ruff checkdoes not catch this (F811) because.pre-commit-config.yamlexcludes^(tests/|docs/|examples/)from theruff-checkhook.Fix
Renames the second definition to
test_annotation_applies_to_next_assign, taking the name from its own inline comment, and leavestest_annotated_assignon the L111 body that actually tests an annotated assignment. One line changed.Verification
Both tests were run against the real
SingleStaticAssignPass(the upstreamsrc/gt4py/next/ffront/ast_passes/single_static_assign.py, with onlyfbuiltins.TYPE_BUILTIN_NAMESsupplied, to keep the check dependency-free):29 passed30 passedSo the restored test passes as written — this only adds the missing coverage, it does not turn CI red.
Also checked:
ruff format --diffreports "1 file already formatted" both before and after, andruff check --select F811goes from 1 error to clean.Happy to flip which of the two keeps the
test_annotated_assignname, or to use a different name for the renamed one, if you'd prefer.🤖 Generated with Claude Code