Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
sqlite3.test.regression.RegressionTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def CheckPragmaUserVersion
def CheckPragmaSchemaVersion
def CheckStatementReset
def CheckColumnNameWithSpaces
def CheckStatementFinalizationOnCloseDb
def CheckOnConflictRollback
def CheckWorkaroundForBuggySqliteTransferBindings
def CheckEmptyStatement
def CheckTypeMapUsage
def CheckErrorMsgDecodeError
def CheckRegisterAdapter
def CheckSetIsolationLevel
def CheckCursorConstructorCallCheck
def CheckStrSubclass
def CheckConnectionConstructorCallCheck
def CheckCursorRegistration
def CheckAutoCommit
def CheckPragmaAutocommit
def CheckSetDict
def CheckConnectionCall
def CheckCollation

Public Attributes

 con

Detailed Description

Definition at line 28 of file regression.py.


Member Function Documentation

Verifies that creating a connection in autocommit mode works.
2.5.3 introduced a regression so that these could no longer
be created.

Definition at line 232 of file regression.py.

00232 
00233     def CheckAutoCommit(self):
00234         """
00235         Verifies that creating a connection in autocommit mode works.
00236         2.5.3 introduced a regression so that these could no longer
00237         be created.
00238         """
00239         con = sqlite.connect(":memory:", isolation_level=None)

Definition at line 277 of file regression.py.

00277 
00278     def CheckCollation(self):
00279         def collation_cb(a, b):
00280             return 1
00281         self.assertRaises(sqlite.ProgrammingError, self.con.create_collation,
00282             # Lone surrogate cannot be encoded to the default encoding (utf8)
00283             "\uDC80", collation_cb)

Here is the call graph for this function:

Definition at line 65 of file regression.py.

00065 
00066     def CheckColumnNameWithSpaces(self):
00067         cur = self.con.cursor()
00068         cur.execute('select 1 as "foo bar [datetime]"')
00069         self.assertEqual(cur.description[0][0], "foo bar")
00070 
00071         cur.execute('select 1 as "foo baz"')
00072         self.assertEqual(cur.description[0][0], "foo baz")

Here is the call graph for this function:

Call a connection with a non-string SQL request: check error handling
of the statement constructor.

Definition at line 270 of file regression.py.

00270 
00271     def CheckConnectionCall(self):
00272         """
00273         Call a connection with a non-string SQL request: check error handling
00274         of the statement constructor.
00275         """
00276         self.assertRaises(sqlite.Warning, self.con, 1)

Here is the call graph for this function:

Verifies that connection methods check wether base class __init__ was called.

Definition at line 188 of file regression.py.

00188 
00189     def CheckConnectionConstructorCallCheck(self):
00190         """
00191         Verifies that connection methods check wether base class __init__ was called.
00192         """
00193         class Connection(sqlite.Connection):
00194             def __init__(self, name):
00195                 pass
00196 
00197         con = Connection(":memory:")
00198         try:
00199             cur = con.cursor()
00200             self.fail("should have raised ProgrammingError")
00201         except sqlite.ProgrammingError:
00202             pass
00203         except:
00204             self.fail("should have raised ProgrammingError")

Here is the call graph for this function:

Verifies that cursor methods check wether base class __init__ was called.

Definition at line 162 of file regression.py.

00162 
00163     def CheckCursorConstructorCallCheck(self):
00164         """
00165         Verifies that cursor methods check wether base class __init__ was called.
00166         """
00167         class Cursor(sqlite.Cursor):
00168             def __init__(self, con):
00169                 pass
00170 
00171         con = sqlite.connect(":memory:")
00172         cur = Cursor(con)
00173         try:
00174             cur.execute("select 4+5").fetchall()
00175             self.fail("should have raised ProgrammingError")
00176         except sqlite.ProgrammingError:
00177             pass
00178         except:
00179             self.fail("should have raised ProgrammingError")
00180 

Here is the call graph for this function:

Verifies that subclassed cursor classes are correctly registered with
the connection object, too.  (fetch-across-rollback problem)

Definition at line 205 of file regression.py.

00205 
00206     def CheckCursorRegistration(self):
00207         """
00208         Verifies that subclassed cursor classes are correctly registered with
00209         the connection object, too.  (fetch-across-rollback problem)
00210         """
00211         class Connection(sqlite.Connection):
00212             def cursor(self):
00213                 return Cursor(self)
00214 
00215         class Cursor(sqlite.Cursor):
00216             def __init__(self, con):
00217                 sqlite.Cursor.__init__(self, con)
00218 
00219         con = Connection(":memory:")
00220         cur = con.cursor()
00221         cur.execute("create table foo(x)")
00222         cur.executemany("insert into foo(x) values (?)", [(3,), (4,), (5,)])
00223         cur.execute("select x from foo")
00224         con.rollback()
00225         try:
00226             cur.fetchall()
00227             self.fail("should have raised InterfaceError")
00228         except sqlite.InterfaceError:
00229             pass
00230         except:
00231             self.fail("should have raised InterfaceError")

Here is the call graph for this function:

pysqlite used to segfault with SQLite versions 3.5.x. These return NULL
for "no-operation" statements

Definition at line 112 of file regression.py.

00112 
00113     def CheckEmptyStatement(self):
00114         """
00115         pysqlite used to segfault with SQLite versions 3.5.x. These return NULL
00116         for "no-operation" statements
00117         """
00118         self.con.execute("")

Definition at line 134 of file regression.py.

00134 
00135     def CheckErrorMsgDecodeError(self):
00136         # When porting the module to Python 3.0, the error message about
00137         # decoding errors disappeared. This verifies they're back again.
00138         failure = None
00139         try:
00140             self.con.execute("select 'xxx' || ? || 'yyy' colname",
00141                              (bytes(bytearray([250])),)).fetchone()
00142             failure = "should have raised an OperationalError with detailed description"
00143         except sqlite.OperationalError as e:
00144             msg = e.args[0]
00145             if not msg.startswith("Could not decode to UTF-8 column 'colname' with text 'xxx"):
00146                 failure = "OperationalError did not have expected description text"
00147         if failure:
00148             self.fail(failure)

Here is the call graph for this function:

Definition at line 87 of file regression.py.

00087 
00088     def CheckOnConflictRollback(self):
00089         if sqlite.sqlite_version_info < (3, 2, 2):
00090             return
00091         con = sqlite.connect(":memory:")
00092         con.execute("create table foo(x, unique(x) on conflict rollback)")
00093         con.execute("insert into foo(x) values (1)")
00094         try:
00095             con.execute("insert into foo(x) values (1)")
00096         except sqlite.DatabaseError:
00097             pass
00098         con.execute("insert into foo(x) values (2)")
00099         try:
00100             con.commit()
00101         except sqlite.OperationalError:
00102             self.fail("pysqlite knew nothing about the implicit ROLLBACK")

Here is the call graph for this function:

Verifies that running a PRAGMA statement that does an autocommit does
work. This did not work in 2.5.3/2.5.4.

Definition at line 240 of file regression.py.

00240 
00241     def CheckPragmaAutocommit(self):
00242         """
00243         Verifies that running a PRAGMA statement that does an autocommit does
00244         work. This did not work in 2.5.3/2.5.4.
00245         """
00246         cur = self.con.cursor()
00247         cur.execute("create table foo(bar)")
00248         cur.execute("insert into foo(bar) values (5)")
00249 
00250         cur.execute("pragma page_size")
00251         row = cur.fetchone()

Definition at line 40 of file regression.py.

00040 
00041     def CheckPragmaSchemaVersion(self):
00042         # This still crashed pysqlite <= 2.2.1
00043         con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES)
00044         try:
00045             cur = self.con.cursor()
00046             cur.execute("pragma schema_version")
00047         finally:
00048             cur.close()
00049             con.close()

Definition at line 35 of file regression.py.

00035 
00036     def CheckPragmaUserVersion(self):
00037         # This used to crash pysqlite because this pragma command returns NULL for the column name
00038         cur = self.con.cursor()
00039         cur.execute("pragma user_version")

See issue 3312.

Definition at line 149 of file regression.py.

00149 
00150     def CheckRegisterAdapter(self):
00151         """
00152         See issue 3312.
00153         """
00154         self.assertRaises(TypeError, sqlite.register_adapter, {}, None)

Here is the call graph for this function:

See http://bugs.python.org/issue7478

It was possible to successfully register callbacks that could not be
hashed. Return codes of PyDict_SetItem were not checked properly.

Definition at line 252 of file regression.py.

00252 
00253     def CheckSetDict(self):
00254         """
00255         See http://bugs.python.org/issue7478
00256 
00257         It was possible to successfully register callbacks that could not be
00258         hashed. Return codes of PyDict_SetItem were not checked properly.
00259         """
00260         class NotHashable:
00261             def __call__(self, *args, **kw):
00262                 pass
00263             def __hash__(self):
00264                 raise TypeError()
00265         var = NotHashable()
00266         self.assertRaises(TypeError, self.con.create_function, var)
00267         self.assertRaises(TypeError, self.con.create_aggregate, var)
00268         self.assertRaises(TypeError, self.con.set_authorizer, var)
00269         self.assertRaises(TypeError, self.con.set_progress_handler, var)

See issue 3312.

Definition at line 155 of file regression.py.

00155 
00156     def CheckSetIsolationLevel(self):
00157         """
00158         See issue 3312.
00159         """
00160         con = sqlite.connect(":memory:")
00161         setattr(con, "isolation_level", "\xe9")

Definition at line 73 of file regression.py.

00073 
00074     def CheckStatementFinalizationOnCloseDb(self):
00075         # pysqlite versions <= 2.3.3 only finalized statements in the statement
00076         # cache when closing the database. statements that were still
00077         # referenced in cursors weren't closed an could provoke "
00078         # "OperationalError: Unable to close due to unfinalised statements".
00079         con = sqlite.connect(":memory:")
00080         cursors = []
00081         # default statement cache size is 100
00082         for i in range(105):
00083             cur = con.cursor()
00084             cursors.append(cur)
00085             cur.execute("select 1 x union select " + str(i))
00086         con.close()

Definition at line 50 of file regression.py.

00050 
00051     def CheckStatementReset(self):
00052         # pysqlite 2.1.0 to 2.2.0 have the problem that not all statements are
00053         # reset before a rollback, but only those that are still in the
00054         # statement cache. The others are not accessible from the connection object.
00055         con = sqlite.connect(":memory:", cached_statements=5)
00056         cursors = [con.cursor() for x in range(5)]
00057         cursors[0].execute("create table test(x)")
00058         for i in range(10):
00059             cursors[0].executemany("insert into test(x) values (?)", [(x,) for x in range(10)])
00060 
00061         for i in range(5):
00062             cursors[i].execute(" " * i + "select x from test")
00063 
00064         con.rollback()

Here is the call graph for this function:

The Python 3.0 port of the module didn't cope with values of subclasses of str.

Definition at line 181 of file regression.py.

00181 
00182     def CheckStrSubclass(self):
00183         """
00184         The Python 3.0 port of the module didn't cope with values of subclasses of str.
00185         """
00186         class MyStr(str): pass
00187         self.con.execute("select ?", (MyStr("abc"),))

pysqlite until 2.4.1 did not rebuild the row_cast_map when recompiling
a statement. This test exhibits the problem.

Definition at line 119 of file regression.py.

00119 
00120     def CheckTypeMapUsage(self):
00121         """
00122         pysqlite until 2.4.1 did not rebuild the row_cast_map when recompiling
00123         a statement. This test exhibits the problem.
00124         """
00125         SELECT = "select * from foo"
00126         con = sqlite.connect(":memory:",detect_types=sqlite.PARSE_DECLTYPES)
00127         con.execute("create table foo(bar timestamp)")
00128         con.execute("insert into foo(bar) values (?)", (datetime.datetime.now(),))
00129         con.execute(SELECT)
00130         con.execute("drop table foo")
00131         con.execute("create table foo(bar integer)")
00132         con.execute("insert into foo(bar) values (5)")
00133         con.execute(SELECT)

Here is the call graph for this function:

pysqlite would crash with older SQLite versions unless
a workaround is implemented.

Definition at line 103 of file regression.py.

00103 
00104     def CheckWorkaroundForBuggySqliteTransferBindings(self):
00105         """
00106         pysqlite would crash with older SQLite versions unless
00107         a workaround is implemented.
00108         """
00109         self.con.execute("create table foo(bar)")
00110         self.con.execute("drop table foo")
00111         self.con.execute("create table foo(bar)")

Definition at line 29 of file regression.py.

00029 
00030     def setUp(self):
00031         self.con = sqlite.connect(":memory:")

Here is the caller graph for this function:

Definition at line 32 of file regression.py.

00032 
00033     def tearDown(self):
00034         self.con.close()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 30 of file regression.py.


The documentation for this class was generated from the following file: