aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_sqlite3/test_dbapi.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_sqlite3/test_dbapi.py')
-rw-r--r--Lib/test/test_sqlite3/test_dbapi.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_sqlite3/test_dbapi.py b/Lib/test/test_sqlite3/test_dbapi.py
index 3013abfa730..1bb0e13e356 100644
--- a/Lib/test/test_sqlite3/test_dbapi.py
+++ b/Lib/test/test_sqlite3/test_dbapi.py
@@ -577,6 +577,30 @@ class ConnectionTests(unittest.TestCase):
cx.executemany, "insert into t values(?)",
((v,) for v in range(3)))
+ def test_connection_config(self):
+ op = sqlite.SQLITE_DBCONFIG_ENABLE_FKEY
+ with memory_database() as cx:
+ with self.assertRaisesRegex(ValueError, "unknown"):
+ cx.getconfig(-1)
+
+ # Toggle and verify.
+ old = cx.getconfig(op)
+ new = not old
+ cx.setconfig(op, new)
+ self.assertEqual(cx.getconfig(op), new)
+
+ cx.setconfig(op) # defaults to True
+ self.assertTrue(cx.getconfig(op))
+
+ # Check that foreign key support was actually enabled.
+ with cx:
+ cx.executescript("""
+ create table t(t integer primary key);
+ create table u(u, foreign key(u) references t(t));
+ """)
+ with self.assertRaisesRegex(sqlite.IntegrityError, "constraint"):
+ cx.execute("insert into u values(0)")
+
class UninitialisedConnectionTests(unittest.TestCase):
def setUp(self):