Skip to content

bpo-45181: Simplify loading sqlite3 tests #28304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,5 @@ def test_database_source_name(self):
self.verify_backup(bck)


def suite():
return unittest.TestLoader().loadTestsFromTestCase(BackupTests)

if __name__ == "__main__":
unittest.main()
25 changes: 1 addition & 24 deletions Lib/sqlite3/test/dbapi.py → Lib/sqlite3/test/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,28 +1156,5 @@ def wait():
self.assertEqual(proc.returncode, 0)


def suite():
tests = [
ClosedConTests,
ClosedCurTests,
ConnectionTests,
ConstructorTests,
CursorTests,
ExtensionTests,
ModuleTests,
MultiprocessTests,
OpenTests,
SqliteOnConflictTests,
ThreadTests,
UninitialisedConnectionTests,
]
return unittest.TestSuite(
[unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
)

def test():
runner = unittest.TextTestRunner()
runner.run(suite())

if __name__ == "__main__":
test()
unittest.main()
13 changes: 1 addition & 12 deletions Lib/sqlite3/test/dump.py → Lib/sqlite3/test/test_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@ def __getitem__(self, index):
got = list(self.cx.iterdump())
self.assertEqual(expected, got)

def suite():
tests = [
DumpTests,
]
return unittest.TestSuite(
[unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
)

def test():
runner = unittest.TextTestRunner()
runner.run(suite())

if __name__ == "__main__":
test()
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -305,22 +305,6 @@ def test_custom(self):
def tearDown(self):
self.con.close()

def suite():
tests = [
ConnectionFactoryTests,
CursorFactoryTests,
RowFactoryTests,
RowFactoryTestsBackwardsCompat,
TextFactoryTests,
TextFactoryTestsWithEmbeddedZeroBytes,
]
return unittest.TestSuite(
[unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
)

def test():
runner = unittest.TextTestRunner()
runner.run(suite())

if __name__ == "__main__":
test()
unittest.main()
18 changes: 2 additions & 16 deletions Lib/sqlite3/test/hooks.py → Lib/sqlite3/test/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import sqlite3 as sqlite

from test.support.os_helper import TESTFN, unlink
from .userfunctions import with_tracebacks
from .test_userfunctions import with_tracebacks

class CollationTests(unittest.TestCase):
def test_create_collation_not_string(self):
Expand Down Expand Up @@ -290,19 +290,5 @@ def trace(statement):
self.assertEqual(traced_statements, queries)


def suite():
tests = [
CollationTests,
ProgressTests,
TraceCallbackTests,
]
return unittest.TestSuite(
[unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
)

def test():
runner = unittest.TextTestRunner()
runner.run(suite())

if __name__ == "__main__":
test()
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,5 @@ def test_return_empty_bytestring(self):
self.assertEqual(val, b'')


def suite():
tests = [
RegressionTests
]
return unittest.TestSuite(
[unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
)

def test():
runner = unittest.TextTestRunner()
runner.run(suite())

if __name__ == "__main__":
test()
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,6 @@ def test_transactional_ddl(self):
def tearDown(self):
self.con.close()

def suite():
tests = [
SpecialCommandTests,
TransactionTests,
TransactionalDDL,
]
return unittest.TestSuite(
[unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
)

def test():
runner = unittest.TextTestRunner()
runner.run(suite())

if __name__ == "__main__":
test()
unittest.main()
19 changes: 1 addition & 18 deletions Lib/sqlite3/test/types.py → Lib/sqlite3/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,23 +530,6 @@ def test_date_time_sub_seconds_floating_point(self):
ts2 = self.cur.fetchone()[0]
self.assertEqual(ts, ts2)

def suite():
tests = [
BinaryConverterTests,
ColNamesTests,
CommonTableExpressionTests,
DateTimeTests,
DeclTypesTests,
ObjectAdaptationTests,
SqliteTypeTests,
]
return unittest.TestSuite(
[unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
)

def test():
runner = unittest.TextTestRunner()
runner.run(suite())

if __name__ == "__main__":
test()
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -661,22 +661,5 @@ def authorizer_cb(action, arg1, arg2, dbname, source):
return sqlite.SQLITE_OK


def suite():
tests = [
AggregateTests,
AuthorizerIllegalTypeTests,
AuthorizerLargeIntegerTests,
AuthorizerRaiseExceptionTests,
AuthorizerTests,
FunctionTests,
]
return unittest.TestSuite(
[unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
)

def test():
runner = unittest.TextTestRunner()
runner.run(suite())

if __name__ == "__main__":
test()
unittest.main()
16 changes: 5 additions & 11 deletions Lib/test/test_sqlite.py
Original file line number Diff line number Diff line change
@@ -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()