Skip to content

fix #23: [14] Guard against uncollected nested test functions - #47

Merged
CuriosityQuantified merged 1 commit into
mainfrom
feat/issue-23-nested-test-discovery-guard
Aug 10, 2026
Merged

CuriosityQuantified merged 1 commit into
mainfrom
feat/issue-23-nested-test-discovery-guard

Conversation

@CuriosityQuantified

Copy link
Copy Markdown
Owner

Closes #23

Summary

Issue #23 ([14] Nested test function is unreachable dead code) reported a test_* function defined inside test_create_idea_live_groq_call 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 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

  • NEW tests/unit/test_nested_test_discovery_regression.py — AST-based, fully offline guard (it parses files with ast, never imports/execs them). It scans every tests/unit/test_*.py and fails if any test_* function is nested inside another function. A ClassDef body resets the enclosing-function context, so Test*-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_parsing is defined exactly once at module level;
    • it is not nested inside test_create_idea_live_groq_call.
  • .github/workflows/ci.yml — one named step Run nested test discovery regression in the unit-tests job, mirroring the sibling per-issue regression steps. Deselect list and other jobs untouched.

Verification

  • New regression: 3 passed. Verified it bites — injecting a nested def test_x inside def test_wrapper makes it fail with a precise message, then passes again once removed.
  • Full unit suite (CI deselects): 231 passed / 1 skipped / 6 deselected (baseline was 228; +3 new).
  • Next.js production build (npm run build): green.
  • Playwright e2e job: unaffected — this diff touches no frontend/e2e code.

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

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>
@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
save-the-world Ready Ready Preview Aug 10, 2026 1:04am
sim-local Ready Ready Preview Aug 10, 2026 1:04am

@CuriosityQuantified
CuriosityQuantified merged commit a75f4d8 into main Aug 10, 2026
6 checks passed
@CuriosityQuantified
CuriosityQuantified deleted the feat/issue-23-nested-test-discovery-guard branch August 10, 2026 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[14] Nested test function is unreachable dead code [13] Tests mock the wrong code path — assertions never fail even when code is broken

1 participant