diff options
Diffstat (limited to 'Lib/sqlite3/test')
-rw-r--r-- | Lib/sqlite3/test/hooks.py | 4 | ||||
-rw-r--r-- | Lib/sqlite3/test/regression.py | 27 | ||||
-rw-r--r-- | Lib/sqlite3/test/userfunctions.py | 14 |
3 files changed, 42 insertions, 3 deletions
diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py index 21f7b88..b10b3ef 100644 --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -22,7 +22,7 @@ # 3. This notice may not be removed or altered from any source distribution. import os, unittest -import pysqlite2.dbapi2 as sqlite +import sqlite3 as sqlite class CollationTests(unittest.TestCase): def setUp(self): @@ -72,7 +72,7 @@ class CollationTests(unittest.TestCase): result = con.execute(sql).fetchall() self.fail("should have raised an OperationalError") except sqlite.OperationalError, e: - self.failUnlessEqual(e.args[0], "no such collation sequence: mycoll") + self.failUnlessEqual(e.args[0].lower(), "no such collation sequence: mycoll") def CheckCollationRegisterTwice(self): """ diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index 648ada5..25e4b63 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -22,7 +22,7 @@ # 3. This notice may not be removed or altered from any source distribution. import unittest -import pysqlite2.dbapi2 as sqlite +import sqlite3 as sqlite class RegressionTests(unittest.TestCase): def setUp(self): @@ -36,6 +36,31 @@ class RegressionTests(unittest.TestCase): cur = self.con.cursor() cur.execute("pragma user_version") + def CheckPragmaSchemaVersion(self): + # This still crashed pysqlite <= 2.2.1 + con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES) + try: + cur = self.con.cursor() + cur.execute("pragma schema_version") + finally: + cur.close() + con.close() + + def CheckStatementReset(self): + # pysqlite 2.1.0 to 2.2.0 have the problem that not all statements are + # reset before a rollback, but only those that are still in the + # statement cache. The others are not accessible from the connection object. + con = sqlite.connect(":memory:", cached_statements=5) + cursors = [con.cursor() for x in xrange(5)] + cursors[0].execute("create table test(x)") + for i in range(10): + cursors[0].executemany("insert into test(x) values (?)", [(x,) for x in xrange(10)]) + + for i in range(5): + cursors[i].execute(" " * i + "select x from test") + + con.rollback() + def suite(): regression_suite = unittest.makeSuite(RegressionTests, "Check") return unittest.TestSuite((regression_suite,)) diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py index ff7db9c..78656e7 100644 --- a/Lib/sqlite3/test/userfunctions.py +++ b/Lib/sqlite3/test/userfunctions.py @@ -134,6 +134,13 @@ class FunctionTests(unittest.TestCase): def tearDown(self): self.con.close() + def CheckFuncErrorOnCreate(self): + try: + self.con.create_function("bla", -100, lambda x: 2*x) + self.fail("should have raised an OperationalError") + except sqlite.OperationalError: + pass + def CheckFuncRefCount(self): def getfunc(): def f(): @@ -251,6 +258,13 @@ class AggregateTests(unittest.TestCase): #self.con.close() pass + def CheckAggrErrorOnCreate(self): + try: + self.con.create_function("bla", -100, AggrSum) + self.fail("should have raised an OperationalError") + except sqlite.OperationalError: + pass + def CheckAggrNoStep(self): cur = self.con.cursor() cur.execute("select nostep(t) from test") |