Skip to content

ResourceWarning in coverage report, since 7.0.0 #2017

@sbrudenell

Description

@sbrudenell

Describe the bug
coverage report emits a ResourceWarning, evidently due to never closing its database connection(s). This happens regardless of whether any coverage data is present. I see it in coverage==7.0.0 and later, but not in coverage==6.5.

To Reproduce

$ pip install coverage==7.0.0
$ python -Werror -m coverage report
No data to report.
Exception ignored in: <sqlite3.Connection object at 0x7f6cc3be47c0>
ResourceWarning: unclosed database in <sqlite3.Connection object at 0x7f6cc3be47c0>

Expected behavior
coverage should close its database connections explicitly.

Additional context
This was a speedbump for me, as I'm using pytest-cov, with a command line like pytest --cov --cov-report term-missing. I set my global warning filter to "error", to catch everything.

I can work around this by using a separate invocation of coverage report, but then I don't get the nice behavior of --no-cov-on-fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions