From 3e19409d6443c66a6a7d62f58b2bb4e8330e56c4 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 13 Sep 2021 14:16:26 +0300 Subject: bpo-45181: Simplify loading sqlite3 tests (GH-28304) Use unittest discover instead of manually enumerating all test modules and classes. Also add support for filtering them by pattern. --- Lib/test/test_sqlite.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'Lib/test/test_sqlite.py') diff --git a/Lib/test/test_sqlite.py b/Lib/test/test_sqlite.py index 73002f228f..9992a02e5d 100644 --- a/Lib/test/test_sqlite.py +++ b/Lib/test/test_sqlite.py @@ -1,26 +1,20 @@ import test.support from test.support import import_helper +from test.support import load_package_tests # Skip test if _sqlite3 module not installed import_helper.import_module('_sqlite3') import unittest -import sqlite3 -from sqlite3.test import (dbapi, types, userfunctions, - factory, transactions, hooks, regression, - dump, backup) +import os +import sqlite3.test -def load_tests(*args): +def load_tests(loader, tests, pattern): if test.support.verbose: print("test_sqlite: testing with version", "{!r}, sqlite_version {!r}".format(sqlite3.version, sqlite3.sqlite_version)) - return unittest.TestSuite([dbapi.suite(), types.suite(), - userfunctions.suite(), - factory.suite(), transactions.suite(), - hooks.suite(), regression.suite(), - dump.suite(), - backup.suite()]) + return load_package_tests(os.path.dirname(sqlite3.test.__file__), loader, tests, pattern) if __name__ == "__main__": unittest.main() -- cgit v1.2.1