Skip to content

[3.11] gh-108550: Speed up sqlite3 tests (#108551) #108567

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
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
2 changes: 1 addition & 1 deletion Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,7 @@ def test_on_conflict_replace(self):

@requires_subprocess()
class MultiprocessTests(unittest.TestCase):
CONNECTION_TIMEOUT = SHORT_TIMEOUT / 1000. # Defaults to 30 ms
CONNECTION_TIMEOUT = 0 # Disable the busy timeout.

def tearDown(self):
unlink(TESTFN)
Expand Down
16 changes: 6 additions & 10 deletions Lib/test/test_sqlite3/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@
import os, unittest
import sqlite3 as sqlite

from test.support import LOOPBACK_TIMEOUT
from test.support.os_helper import TESTFN, unlink

from test.test_sqlite3.test_dbapi import memory_database


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):
Expand Down Expand Up @@ -117,10 +115,8 @@ def test_raise_timeout(self):
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):
Expand Down