Skip to content

So many warnings in pytest -Wall #692

Closed

Description

@simonw

First reported against the LLM test suite here:

Run this:

uv run pytest -Wall

Output: https://gist.github.com/simonw/15b70ba7f59b1750d8397d899c7b2bdc

Activity

  1. simonw commented on Dec 12, 2025

    @simonw
    OwnerAuthor
  2. simonw commented on Dec 12, 2025

    @simonw
    OwnerAuthor

    Had Claude Code come up with this devious trick to help auto-close databases in tests:

    diff --git a/tests/conftest.py b/tests/conftest.py
    index a9a47bc..29a3b16 100644
    --- a/tests/conftest.py
    +++ b/tests/conftest.py
    @@ -14,6 +14,26 @@ def pytest_configure(config):
         sys._called_from_test = True
     
     
    +@pytest.fixture(autouse=True)
    +def close_all_databases():
    +    """Automatically close all Database objects created during a test."""
    +    databases = []
    +    original_init = Database.__init__
    +
    +    def tracking_init(self, *args, **kwargs):
    +        original_init(self, *args, **kwargs)
    +        databases.append(self)
    +
    +    Database.__init__ = tracking_init
    +    yield
    +    Database.__init__ = original_init
    +    for db in databases:
    +        try:
    +            db.close()
    +        except Exception:
    +            pass
    +
    +
     @pytest.fixture
     def fresh_db():
         db = Database(memory=True)
  3. added 2 commits that reference this issue on Jun 21, 2026
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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions