summaryrefslogtreecommitdiff
path: root/Lib/sqlite3/test/dbapi.py
diff options
context:
space:
mode:
authorGerhard Häring <gh@ghaering.de>2008-03-29 00:45:29 +0000
committerGerhard Häring <gh@ghaering.de>2008-03-29 00:45:29 +0000
commite7ea7451a84636655927da4b9731d2eb37d1cf34 (patch)
tree7862ebdca8d04d799ddeacf4cf74e2a130e376b4 /Lib/sqlite3/test/dbapi.py
parentb1b9382d91e4b2e863225179cde4a61f0300a233 (diff)
downloadcpython-git-e7ea7451a84636655927da4b9731d2eb37d1cf34.tar.gz
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
left out the stuff about creating a connection object from a APSW connection.
Diffstat (limited to 'Lib/sqlite3/test/dbapi.py')
-rw-r--r--Lib/sqlite3/test/dbapi.py51
1 files changed, 36 insertions, 15 deletions
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index 6d4c4fed02..8327aa195b 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -1,7 +1,7 @@
#-*- coding: ISO-8859-1 -*-
# pysqlite2/test/dbapi.py: tests for DB-API compliance
#
-# Copyright (C) 2004-2005 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2004-2007 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
@@ -223,12 +223,41 @@ class CursorTests(unittest.TestCase):
except sqlite.ProgrammingError:
pass
+ def CheckExecuteParamList(self):
+ self.cu.execute("insert into test(name) values ('foo')")
+ self.cu.execute("select name from test where name=?", ["foo"])
+ row = self.cu.fetchone()
+ self.failUnlessEqual(row[0], "foo")
+
+ def CheckExecuteParamSequence(self):
+ class L(object):
+ def __len__(self):
+ return 1
+ def __getitem__(self, x):
+ assert x == 0
+ return "foo"
+
+ self.cu.execute("insert into test(name) values ('foo')")
+ self.cu.execute("select name from test where name=?", L())
+ row = self.cu.fetchone()
+ self.failUnlessEqual(row[0], "foo")
+
def CheckExecuteDictMapping(self):
self.cu.execute("insert into test(name) values ('foo')")
self.cu.execute("select name from test where name=:name", {"name": "foo"})
row = self.cu.fetchone()
self.failUnlessEqual(row[0], "foo")
+ def CheckExecuteDictMapping_Mapping(self):
+ class D(dict):
+ def __missing__(self, key):
+ return "foo"
+
+ self.cu.execute("insert into test(name) values ('foo')")
+ self.cu.execute("select name from test where name=:name", D())
+ row = self.cu.fetchone()
+ self.failUnlessEqual(row[0], "foo")
+
def CheckExecuteDictMappingTooLittleArgs(self):
self.cu.execute("insert into test(name) values ('foo')")
try:
@@ -378,6 +407,12 @@ class CursorTests(unittest.TestCase):
res = self.cu.fetchmany(100)
self.failUnlessEqual(res, [])
+ def CheckFetchmanyKwArg(self):
+ """Checks if fetchmany works with keyword arguments"""
+ self.cu.execute("select name from test")
+ res = self.cu.fetchmany(size=100)
+ self.failUnlessEqual(len(res), 1)
+
def CheckFetchall(self):
self.cu.execute("select name from test")
res = self.cu.fetchall()
@@ -609,20 +644,6 @@ class ExtensionTests(unittest.TestCase):
res = cur.fetchone()[0]
self.failUnlessEqual(res, 5)
- def CheckScriptStringUnicode(self):
- con = sqlite.connect(":memory:")
- cur = con.cursor()
- cur.executescript("""
- create table a(i);
- insert into a(i) values (5);
- select i from a;
- delete from a;
- insert into a(i) values (6);
- """)
- cur.execute("select i from a")
- res = cur.fetchone()[0]
- self.failUnlessEqual(res, 6)
-
def CheckScriptErrorIncomplete(self):
con = sqlite.connect(":memory:")
cur = con.cursor()