From 869a48a5a0ae8c9e8c5eede137fc9cc72babe0dd Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Sun, 16 Nov 2025 15:36:10 +0800 Subject: [PATCH 1/2] fix: do not print the message twice in sqlite test verbose Signed-off-by: yihong0618 --- Lib/test/test_sqlite3/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_sqlite3/__init__.py b/Lib/test/test_sqlite3/__init__.py index 78a1e2078a5da0..bd739e102401cf 100644 --- a/Lib/test/test_sqlite3/__init__.py +++ b/Lib/test/test_sqlite3/__init__.py @@ -7,8 +7,9 @@ import sqlite3 # Implement the unittest "load tests" protocol. -def load_tests(*args): - if verbose: +def load_tests(loader, tests, pattern): + # Only print on the top-level call + if verbose and pattern is None: print(f"test_sqlite3: testing with SQLite version {sqlite3.sqlite_version}") pkg_dir = os.path.dirname(__file__) - return load_package_tests(pkg_dir, *args) + return load_package_tests(pkg_dir, loader, tests, pattern) From e963e2f5f98e638b8a85292866bd2455544216de Mon Sep 17 00:00:00 2001 From: yihong0618 Date: Wed, 19 Nov 2025 08:26:22 +0800 Subject: [PATCH 2/2] fix: use global instead of pattern Signed-off-by: yihong0618 --- Lib/test/test_sqlite3/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_sqlite3/__init__.py b/Lib/test/test_sqlite3/__init__.py index bd739e102401cf..145f3b80024829 100644 --- a/Lib/test/test_sqlite3/__init__.py +++ b/Lib/test/test_sqlite3/__init__.py @@ -6,10 +6,14 @@ import os import sqlite3 +# make sure only print once +_printed_version = False + # Implement the unittest "load tests" protocol. def load_tests(loader, tests, pattern): - # Only print on the top-level call - if verbose and pattern is None: + global _printed_version + if verbose and not _printed_version: print(f"test_sqlite3: testing with SQLite version {sqlite3.sqlite_version}") + _printed_version = True pkg_dir = os.path.dirname(__file__) return load_package_tests(pkg_dir, loader, tests, pattern)