home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import datetime
- import unittest
- import sqlite3 as sqlite
-
- class RegressionTests(unittest.TestCase):
-
- def setUp(self):
- self.con = sqlite.connect(':memory:')
-
-
- def tearDown(self):
- self.con.close()
-
-
- def CheckPragmaUserVersion(self):
- cur = self.con.cursor()
- cur.execute('pragma user_version')
-
-
- def CheckPragmaSchemaVersion(self):
- 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):
- 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):
- []([], [ (x,) for x in xrange(10) ])
-
- for i in range(5):
- cursors[i].execute(' ' * i + 'select x from test')
-
- con.rollback()
-
-
- def CheckColumnNameWithSpaces(self):
- cur = self.con.cursor()
- cur.execute('select 1 as "foo bar [datetime]"')
- self.failUnlessEqual(cur.description[0][0], 'foo bar')
- cur.execute('select 1 as "foo baz"')
- self.failUnlessEqual(cur.description[0][0], 'foo baz')
-
-
- def CheckStatementAvailable(self):
- con = sqlite.connect(':memory:', detect_types = sqlite.PARSE_DECLTYPES)
- cur = con.cursor()
- cur.execute('select 4 union select 5')
- cur.close()
- cur.fetchone()
- cur.fetchone()
-
-
- def CheckStatementFinalizationOnCloseDb(self):
- con = sqlite.connect(':memory:')
- cursors = []
- for i in range(105):
- cur = con.cursor()
- cursors.append(cur)
- cur.execute('select 1 x union select ' + str(i))
-
- con.close()
-
-
- def CheckOnConflictRollback(self):
- if sqlite.sqlite_version_info < (3, 2, 2):
- return None
- con = sqlite.connect(':memory:')
- con.execute('create table foo(x, unique(x) on conflict rollback)')
- con.execute('insert into foo(x) values (1)')
-
- try:
- con.execute('insert into foo(x) values (1)')
- except sqlite.DatabaseError:
- sqlite.sqlite_version_info < (3, 2, 2)
- sqlite.sqlite_version_info < (3, 2, 2)
- except:
- sqlite.sqlite_version_info < (3, 2, 2)
-
- con.execute('insert into foo(x) values (2)')
-
- try:
- con.commit()
- except sqlite.OperationalError:
- sqlite.sqlite_version_info < (3, 2, 2)
- sqlite.sqlite_version_info < (3, 2, 2)
- self.fail('pysqlite knew nothing about the implicit ROLLBACK')
- except:
- sqlite.sqlite_version_info < (3, 2, 2)
-
-
-
- def CheckWorkaroundForBuggySqliteTransferBindings(self):
- self.con.execute('create table foo(bar)')
- self.con.execute('drop table foo')
- self.con.execute('create table foo(bar)')
-
-
- def CheckEmptyStatement(self):
- self.con.execute('')
-
-
- def CheckUnicodeConnect(self):
- con = sqlite.connect(u':memory:')
- con.close()
-
-
- def CheckTypeMapUsage(self):
- SELECT = 'select * from foo'
- con = sqlite.connect(':memory:', detect_types = sqlite.PARSE_DECLTYPES)
- con.execute('create table foo(bar timestamp)')
- con.execute('insert into foo(bar) values (?)', (datetime.datetime.now(),))
- con.execute(SELECT)
- con.execute('drop table foo')
- con.execute('create table foo(bar integer)')
- con.execute('insert into foo(bar) values (5)')
- con.execute(SELECT)
-
-
- def CheckRegisterAdapter(self):
- self.assertRaises(TypeError, sqlite.register_adapter, { }, None)
-
-
- def CheckSetIsolationLevel(self):
- con = sqlite.connect(':memory:')
- self.assertRaises(UnicodeEncodeError, setattr, con, 'isolation_level', u'é')
-
-
-
- def suite():
- regression_suite = unittest.makeSuite(RegressionTests, 'Check')
- return unittest.TestSuite((regression_suite,))
-
-
- def test():
- runner = unittest.TextTestRunner()
- runner.run(suite())
-
- if __name__ == '__main__':
- test()
-
-