Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
gh-94998: Make 3.10 sqlite3 tests run
Add __init__ and __main__ to test_sqlite3 directory.
In test_dbapi, comment out cx_limit, line 42.
Add 'verbosity=2' to unittest.main().
  • Loading branch information
terryjreedy committed Jul 19, 2022
commit b42b4ee44c56b71d5f89aea3067ebf70d5f4fa49
18 changes: 18 additions & 0 deletions Lib/test/test_sqlite3/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from test.support import import_helper, load_package_tests, verbose

# Skip test if _sqlite3 module not installed.
import_helper.import_module('_sqlite3')

import unittest
import os
import sqlite3

# Implement the unittest "load tests" protocol.
def load_tests(*args):
pkg_dir = os.path.dirname(__file__)
return load_package_tests(pkg_dir, *args)

if verbose:
print("test_sqlite3: testing with version",
"{!r}, sqlite_version {!r}".format(sqlite3.version,
sqlite3.sqlite_version))
4 changes: 4 additions & 0 deletions Lib/test/test_sqlite3/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#from test.test_sqlite3 import load_tests
import unittest

unittest.main('test.test_sqlite3')
18 changes: 9 additions & 9 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ def memory_database(*args, **kwargs):
return contextlib.closing(cx)


# Temporarily limit a database connection parameter
@contextlib.contextmanager
def cx_limit(cx, category=sqlite.SQLITE_LIMIT_SQL_LENGTH, limit=128):
try:
_prev = cx.setlimit(category, limit)
yield limit
finally:
cx.setlimit(category, _prev)
### Temporarily limit a database connection parameter
##@contextlib.contextmanager
##def cx_limit(cx, category=sqlite.SQLITE_LIMIT_SQL_LENGTH, limit=128):
## try:
## _prev = cx.setlimit(category, limit)
## yield limit
## finally:
## cx.setlimit(category, _prev)


class ModuleTests(unittest.TestCase):
Expand Down Expand Up @@ -1889,4 +1889,4 @@ def wait():


if __name__ == "__main__":
unittest.main()
unittest.main(verbosity=2)