mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
bpo-40956: Convert sqlite3.connect and sqlite3.Connection.__init__ to AC (GH-24421)
This commit is contained in:
parent
09eb817115
commit
185ecdc146
6 changed files with 298 additions and 71 deletions
|
@ -27,6 +27,7 @@ import threading
|
|||
import unittest
|
||||
|
||||
from test.support.os_helper import TESTFN, unlink
|
||||
from test.support import threading_helper
|
||||
|
||||
|
||||
# Helper for tests using TESTFN
|
||||
|
@ -224,6 +225,10 @@ class OpenTests(unittest.TestCase):
|
|||
with managed_connect(f"file:{TESTFN}?mode=ro", uri=True) as cx:
|
||||
cx.execute(self._sql)
|
||||
|
||||
def test_database_keyword(self):
|
||||
with sqlite.connect(database=":memory:") as cx:
|
||||
self.assertEqual(type(cx), sqlite.Connection)
|
||||
|
||||
|
||||
class CursorTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -724,6 +729,22 @@ class ThreadTests(unittest.TestCase):
|
|||
if len(errors) > 0:
|
||||
self.fail("\n".join(errors))
|
||||
|
||||
@threading_helper.reap_threads
|
||||
def test_dont_check_same_thread(self):
|
||||
def run(con, err):
|
||||
try:
|
||||
con.execute("select 1")
|
||||
except sqlite.Error:
|
||||
err.append("multi-threading not allowed")
|
||||
|
||||
con = sqlite.connect(":memory:", check_same_thread=False)
|
||||
err = []
|
||||
t = threading.Thread(target=run, kwargs={"con": con, "err": err})
|
||||
t.start()
|
||||
t.join()
|
||||
self.assertEqual(len(err), 0, "\n".join(err))
|
||||
|
||||
|
||||
class ConstructorTests(unittest.TestCase):
|
||||
def test_date(self):
|
||||
d = sqlite.Date(2004, 10, 28)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue