Skip to content

python tests: unittest.main() mid-file in two suites — direct-script runs silently skip the classes after it (cold-store #2797 stall tests, nixpkgs-inputs #4553 gate tests) #5712

Closed

Description

@dezren39

Two Python suites carry unittest.main() mid-file — direct-script runs silently skip every test class defined after it

Verified on main af0847d00a2231c71f6ebb59eba4cc7db197599e (2026-11-04, gh api raw reads + executed copies of the committed files).

Evidence

1. pkgs/cold-store-reaper/tests/test_cold_store.py

  • Lines 3223–3224: if __name__ == "__main__": unittest.main(verbosity=2) — mid-file.
  • Line 3227: class TestResumableUploadStalls(ColdStoreTestBase) is defined after that guard, with 3 tests (lines 3252, 3261, 3270). They are the regression tests for closed cold-store-reaper: resumable upload loops forever on a 308 whose Range stops advancing — no progress check or retry cap, and a Range-less 308 counts unacknowledged bytes as sent #2797: a resumable-upload 308 whose Range stops advancing must raise instead of looping forever, and a Range-less 308 must not count unacknowledged bytes as sent.
  • The file's own header (lines 4–5) documents two run modes: python3 -m unittest discover -s pkgs/cold-store-reaper/tests -v or python3 pkgs/cold-store-reaper/tests/test_cold_store.py.
  • Executed this run from a verbatim copy of the committed files (+ cold_store.py, schema.sql):
    • Direct: python3 tests/test_cold_store.py → Ran 109 tests; zero TestResumableUploadStalls tests appear.
    • Discover: python3 -m unittest discover -s tests -v → Ran 112 tests; all 3 stall tests run and pass.
    • (13 failures in both modes in the verification copy are an artifact of the partial copy — missing scripts/drill_compare.py / export-turso fixtures — identical in both modes and unrelated.)
  • CI (.github/workflows/cold-store-reaper.yml) uses discover, so CI is not affected; the documented direct-script mode silently is.

2. scripts/tests/test_update_nixpkgs_inputs.py

  • Lines 377–378: if __name__ == "__main__": unittest.main() — mid-file, followed by a fresh import block (line ~380) and the entire fix(scripts): gate nixpkgs-unstable input updates on the Hydra channel (cached) revision #4553 section.
  • Defined after the guard: TestHydraGateParsing (line 473, 2 tests), TestGatedPinEndToEnd (line 611, 2 tests), TestHttpsContext (line 671, 1 test) — 5 tests pinning the fix(scripts): gate nixpkgs-unstable input updates on the Hydra channel (cached) revision #4553 Hydra cache-gate contract and the HTTPS-verification-stays-on contract for both copies of update-nixpkgs-inputs.
  • Executed this run from a verbatim copy (with both script copies in place):
    • Direct: python3 scripts/tests/test_update_nixpkgs_inputs.py → Ran 9 tests.
    • Discover: python3 -m unittest discover -s scripts/tests -p 'test_update_nixpkgs_inputs.py' → Ran 14 tests; the 5 after-guard tests run and pass.
    • (1 identical error in both modes is the verification copy's missing repo-root flake.lock — unrelated.)
  • CI (.github/workflows/scripts-test.yml line 31) uses discover, so CI is not affected; a direct run silently is.

Why it matters

unittest.main() raises SystemExit when the module is executed as a script, so any class defined below the guard is never even defined in that process — the suite reports a smaller, green-looking run with no warning. In both files the stranded tests are safety contracts (#2797 upload-stall protection; #4553 pin gating). Anyone verifying a change with the documented/quick direct invocation — exactly what the cold-store header offers — gets illusory coverage. Sibling instance, filed separately because its mechanism differs (dead defs are outside any class, so they never run in any mode): #5710.

A repo-wide scan this run (all 41 Python test files) found exactly these two remaining mid-file-guard instances besides #5710's file.

Acceptance criteria

  • In both files, the if __name__ == "__main__": unittest.main() block is the last executable statement in the file (nothing defined after it).
  • python3 pkgs/cold-store-reaper/tests/test_cold_store.py reports 112 tests (was 109), including the 3 TestResumableUploadStalls tests.
  • python3 scripts/tests/test_update_nixpkgs_inputs.py reports 14 tests (was 9), including TestHydraGateParsing, TestGatedPinEndToEnd, and TestHttpsContext.
  • Discover invocations report the same counts as before the change (112 / 14) and no test outcome changes; no production code is modified.

Activity

  1. added
    kind/testTest coverage, test infrastructure, or test-only fixes
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/lowNice to have; do when convenient
    queue/queuedHas a queued task in the Supabase agent queue
    app/cold-store-reaperPackage/app: cold-store-reaper (pkgs/ or apps/ in this repo)
    on Nov 4, 2026
  2. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 5, 2026
  4. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  5. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    Triage findings (task 9761, verified 2026-11-05)

    Confirmed — still present at current main. Fresh gh api contents reads this run:

    Issue #5712 is OPEN with no hard-stop labels (held, user/owned, do-not-merge, do-not-auto-edit all absent) and no matching PR. The issue's own executed evidence (direct runs 109 vs 112 and 9 vs 14 tests; discover/CI unaffected) stands — nothing on current main has moved either guard.

    Routing: the fix is exactly the issue's acceptance criteria — move each guard block to be the last executable statement in its file, no test content or production code changes. Enqueued as task 9769 (small_fix, repo-health-code-pilot). Issue #5712 stays open for task 9769.

  6. added
    queue/queuedHas a queued task in the Supabase agent queue
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 5, 2026
  7. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  8. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 5, 2026
  9. added a commit that references this issue on Nov 5, 2026
  10. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/cold-store-reaperPackage/app: cold-store-reaper (pkgs/ or apps/ in this repo)kind/testTest coverage, test infrastructure, or test-only fixespriority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions