From 1fe1d2883be5faeb6ded9599d5ead201d4fc2f32 Mon Sep 17 00:00:00 2001 From: Andy Salnikov Date: Wed, 5 Nov 2025 16:35:33 -0800 Subject: [PATCH] Improve handling of ResourceWarning from sqlite3. The patch allows suppressing ResourceWarnings from sqlite3 by specifying filter in command line with -W option. --- CHANGELOG.rst | 11 +++++++++++ src/pytest_cov/plugin.py | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4524aad3..b9af4229 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,17 @@ Changelog ========= +* Improve handling of ResourceWarning from sqlite3. + + The plugin adds warning filter for sqlite3 ``ResourceWarning`` unclosed database (since 6.2.0). + It checks if there is already existing plugin for this message by comparing filter regular expression. + When filter is specified on command line the message is escaped and does not match an expected message. + A check for an escaped regular expression is added to handle this case. + + With this fix one can suppress ``ResourceWarning`` from sqlite3 from command line:: + + pytest -W "ignore:unclosed database in