Skip to content

fix(resources): close completion and test-owned database handles - #175

Merged
codeasier merged 1 commit into
mainfrom
test/issue-165-resources
Oct 3, 2026
Merged

codeasier merged 1 commit into
mainfrom
test/issue-165-resources

Conversation

@codeasier

Copy link
Copy Markdown
Owner

📝 Description

Finish the connection-cleanup portion of #165 after #171.

  • Fix the production device-completion path: sqlite3 context managers commit/rollback but do not close. Use contextlib.closing, with real handle-closed assertions on success and invalid databases.
  • Explicitly close SQLite fixture connections while preserving their transaction context.
  • Close test-owned caches with finalizers. Opt-in service fixtures own only constructors imported by those test modules; they do not patch production constructor bindings or participate in lifecycle tests.
  • Collect cyclic test resources at teardown so warnings are attributable. Make ResourceWarning and PytestUnraisableExceptionWarning errors throughout normal pytest/CI.

🔗 Related Issue

Refs #165; keep the umbrella issue open for typing and CLI decomposition.

🧪 Testing

  • Tests added/updated
  • Fixture provenance: 7 passed before runtime suites.
  • Full suite with coverage and strict warnings: 1186 passed, no resource warnings; total coverage 91.32%.
  • Baseline had 143 SQLite ResourceWarnings. Strict GC-at-teardown also located the completion product leak.
  • Ruff/Black/diff passed; basedpyright 0 errors / 831 existing warnings.

✅ Checklist

  • Code follows project guidelines
  • Fixture ownership and warning policy documented inline
  • Changes tested locally

Snapshot Runtime Provenance

  • Snapshot provenance evaluation completed
    Snapshot provenance decision: no-update
    Snapshot provenance no-update reason: Production change is confined to completion.py; snapshot sources and source mappings are unchanged.

@codeasier
codeasier merged commit c35bdcf into main Oct 3, 2026
6 checks passed
@codeasier
codeasier deleted the test/issue-165-resources branch October 3, 2026 19:18
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.

1 participant