fix #23: [14] Guard against uncollected nested test functions - #47
Merged
CuriosityQuantified merged 1 commit intoAug 10, 2026
Merged
Conversation
Issue #23 reported a `test_*` function defined *inside* another test function in tests/unit/test_llm_service.py. Pytest only collects module-level functions and Test*-class methods, so the nested copy was never run -- dead code masquerading as fallback-parsing coverage. The literal deletion already landed via PR #46 (commit d275ebf, which closed #22) as a side-effect of the same-file mock fix, so nothing is left to delete. What was still missing is a guard against recurrence, which this PR adds following the repo's per-issue regression convention. - tests/unit/test_nested_test_discovery_regression.py: AST-based, offline (parses, never imports/execs) guard that scans every tests/unit/test_*.py and fails if any `test_*` function is nested inside another function. Class-body scopes reset the enclosing-function context so Test*-class methods stay allowed. Two targeted assertions lock in the exact #23 fix: `test_create_idea_final_turn_fallback_parsing` is defined exactly once at module level and is not nested inside `test_create_idea_live_groq_call`. - .github/workflows/ci.yml: add a named "Run nested test discovery regression" step in the unit-tests job, mirroring the sibling per-issue regression steps. Deselect list and other jobs untouched. Local gates: unit suite 231 passed / 1 skipped / 6 deselected (was 228; +3 new); Next.js `npm run build` green. No graphify-out/ or code-graph CI job in this repo, so graph refresh is not applicable. Closes #23 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CuriosityQuantified
deleted the
feat/issue-23-nested-test-discovery-guard
branch
August 10, 2026 01:11
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.
Closes #23
Summary
Issue #23 (
[14] Nested test function is unreachable dead code) reported atest_*function defined insidetest_create_idea_live_groq_callintests/unit/test_llm_service.py. Pytest only collects module-level functions andTest*-class methods, so the nested copy was never run — dead code that masqueraded as fallback-parsing coverage.The literal deletion already landed via PR #46 (commit
d275ebf, which closed #22) as a side-effect of the same file's mock fix, so there is nothing left to delete. What was still missing is a guard against recurrence. This PR adds that guard, following the repo's per-issue regression convention (tests/unit/test_<slug>_regression.py+ a named CI step).Changes
tests/unit/test_nested_test_discovery_regression.py— AST-based, fully offline guard (it parses files withast, never imports/execs them). It scans everytests/unit/test_*.pyand fails if anytest_*function is nested inside another function. AClassDefbody resets the enclosing-function context, soTest*-class methods stay allowed. Two targeted assertions lock in the exact [14] Nested test function is unreachable dead code #23 fix:test_create_idea_final_turn_fallback_parsingis defined exactly once at module level;test_create_idea_live_groq_call..github/workflows/ci.yml— one named stepRun nested test discovery regressionin theunit-testsjob, mirroring the sibling per-issue regression steps. Deselect list and other jobs untouched.Verification
3 passed. Verified it bites — injecting a nesteddef test_xinsidedef test_wrappermakes it fail with a precise message, then passes again once removed.npm run build): green.Pipeline
Four sequential fresh subagents ran in the shared checkout: implementation+CI, code review (APPROVE), simplification (removed one trivial single-use helper), and security review (LOW / clean — no material findings). No
graphify-out/or code-graph CI job exists in this repo, so graph refresh is not applicable.🤖 Generated with Claude Code