summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sqlite3/test_transactions.py
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend@python.org>2023-08-28 12:17:34 (GMT)
committerGitHub <noreply@github.com>2023-08-28 12:17:34 (GMT)
commit0e8b3fc718c8a1c4de558c553d9e05049c1dbec6 (patch)
tree34e24ddfcc25abbfaa5ff350f15156797cc8d1d0 /Lib/test/test_sqlite3/test_transactions.py
parent8db451ceb17cf8ec92c8aed2e0a41c78d07f9f45 (diff)
downloadcpython-0e8b3fc718c8a1c4de558c553d9e05049c1dbec6.zip
cpython-0e8b3fc718c8a1c4de558c553d9e05049c1dbec6.tar.gz
cpython-0e8b3fc718c8a1c4de558c553d9e05049c1dbec6.tar.bz2
gh-108550: Speed up sqlite3 tests (#108551)
Refactor the CLI so we can easily invoke it and mock command-line arguments. Adapt the CLI tests so we no longer have to launch a separate process. Disable the busy handler for all concurrency tests; we have full control over the order of the SQLite C API calls, so we can safely do this. The sqlite3 test suite now completes ~8 times faster than before. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_sqlite3/test_transactions.py')
-rw-r--r--Lib/test/test_sqlite3/test_transactions.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/Lib/test/test_sqlite3/test_transactions.py b/Lib/test/test_sqlite3/test_transactions.py
index b7b231d..a3de7a7 100644
--- a/Lib/test/test_sqlite3/test_transactions.py
+++ b/Lib/test/test_sqlite3/test_transactions.py
@@ -24,7 +24,6 @@ import unittest
import sqlite3 as sqlite
from contextlib import contextmanager
-from test.support import LOOPBACK_TIMEOUT
from test.support.os_helper import TESTFN, unlink
from test.support.script_helper import assert_python_ok
@@ -32,15 +31,14 @@ from .util import memory_database
from .util import MemoryDatabaseMixin
-TIMEOUT = LOOPBACK_TIMEOUT / 10
-
-
class TransactionTests(unittest.TestCase):
def setUp(self):
- self.con1 = sqlite.connect(TESTFN, timeout=TIMEOUT)
+ # We can disable the busy handlers, since we control
+ # the order of SQLite C API operations.
+ self.con1 = sqlite.connect(TESTFN, timeout=0)
self.cur1 = self.con1.cursor()
- self.con2 = sqlite.connect(TESTFN, timeout=TIMEOUT)
+ self.con2 = sqlite.connect(TESTFN, timeout=0)
self.cur2 = self.con2.cursor()
def tearDown(self):
@@ -120,10 +118,8 @@ class TransactionTests(unittest.TestCase):
self.cur2.execute("insert into test(i) values (5)")
def test_locking(self):
- """
- This tests the improved concurrency with pysqlite 2.3.4. You needed
- to roll back con2 before you could commit con1.
- """
+ # This tests the improved concurrency with pysqlite 2.3.4. You needed
+ # to roll back con2 before you could commit con1.
self.cur1.execute("create table test(i)")
self.cur1.execute("insert into test(i) values (5)")
with self.assertRaises(sqlite.OperationalError):