aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/sqlite3/test/dbapi.py
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-06-24 13:56:56 +0200
committerGitHub <noreply@github.com>2021-06-24 12:56:56 +0100
commit2c1ae09764446beda5248759fb99c859e14f1b25 (patch)
treeafd2b070b5aab841d9667251bccaf0294e19d210 /Lib/sqlite3/test/dbapi.py
parent9049ea51eca081984c8ae37dfeb68b75d624e90d (diff)
downloadcpython-2c1ae09764446beda5248759fb99c859e14f1b25.tar.gz
cpython-2c1ae09764446beda5248759fb99c859e14f1b25.zip
bpo-43553: Improve `sqlite3` test coverage (GH-26886)
Diffstat (limited to 'Lib/sqlite3/test/dbapi.py')
-rw-r--r--Lib/sqlite3/test/dbapi.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index 7e44cac76f5..1a4b44188bd 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -26,9 +26,8 @@ import sys
import threading
import unittest
-from test.support import check_disallow_instantiation
+from test.support import check_disallow_instantiation, threading_helper
from test.support.os_helper import TESTFN, unlink
-from test.support import threading_helper
# Helper for tests using TESTFN
@@ -110,6 +109,10 @@ class ModuleTests(unittest.TestCase):
cx = sqlite.connect(":memory:")
check_disallow_instantiation(self, type(cx("select 1")))
+ def test_complete_statement(self):
+ self.assertFalse(sqlite.complete_statement("select t"))
+ self.assertTrue(sqlite.complete_statement("create table t(t);"))
+
class ConnectionTests(unittest.TestCase):
@@ -225,6 +228,20 @@ class ConnectionTests(unittest.TestCase):
self.assertTrue(hasattr(self.cx, exc))
self.assertIs(getattr(sqlite, exc), getattr(self.cx, exc))
+ def test_interrupt_on_closed_db(self):
+ cx = sqlite.connect(":memory:")
+ cx.close()
+ with self.assertRaises(sqlite.ProgrammingError):
+ cx.interrupt()
+
+ def test_interrupt(self):
+ self.assertIsNone(self.cx.interrupt())
+
+ def test_drop_unused_refs(self):
+ for n in range(500):
+ cu = self.cx.execute(f"select {n}")
+ self.assertEqual(cu.fetchone()[0], n)
+
class OpenTests(unittest.TestCase):
_sql = "create table test(id integer)"
@@ -594,6 +611,11 @@ class CursorTests(unittest.TestCase):
new_count = len(res.description)
self.assertEqual(new_count - old_count, 1)
+ def test_same_query_in_multiple_cursors(self):
+ cursors = [self.cx.execute("select 1") for _ in range(3)]
+ for cu in cursors:
+ self.assertEqual(cu.fetchall(), [(1,)])
+
class ThreadTests(unittest.TestCase):
def setUp(self):