Back to index

python3.2  3.2.2
Public Member Functions
sqlite3.test.hooks.ProgressTests Class Reference

List of all members.

Public Member Functions

def CheckProgressHandlerUsed
def CheckOpcodeCount
def CheckCancelOperation
def CheckClearHandler

Detailed Description

Definition at line 108 of file hooks.py.


Member Function Documentation

Test that returning a non-zero value stops the operation in progress.

Definition at line 148 of file hooks.py.

00148 
00149     def CheckCancelOperation(self):
00150         """
00151         Test that returning a non-zero value stops the operation in progress.
00152         """
00153         con = sqlite.connect(":memory:")
00154         progress_calls = []
00155         def progress():
00156             progress_calls.append(None)
00157             return 1
00158         con.set_progress_handler(progress, 1)
00159         curs = con.cursor()
00160         self.assertRaises(
00161             sqlite.OperationalError,
00162             curs.execute,
00163             "create table bar (a, b)")

Here is the call graph for this function:

Test that setting the progress handler to None clears the previously set handler.

Definition at line 164 of file hooks.py.

00164 
00165     def CheckClearHandler(self):
00166         """
00167         Test that setting the progress handler to None clears the previously set handler.
00168         """
00169         con = sqlite.connect(":memory:")
00170         action = 0
00171         def progress():
00172             action = 1
00173             return 0
00174         con.set_progress_handler(progress, 1)
00175         con.set_progress_handler(None, 1)
00176         con.execute("select 1 union select 2 union select 3").fetchall()
00177         self.assertEqual(action, 0, "progress handler was not cleared")

Here is the call graph for this function:

Test that the opcode argument is respected.

Definition at line 125 of file hooks.py.

00125 
00126     def CheckOpcodeCount(self):
00127         """
00128         Test that the opcode argument is respected.
00129         """
00130         con = sqlite.connect(":memory:")
00131         progress_calls = []
00132         def progress():
00133             progress_calls.append(None)
00134             return 0
00135         con.set_progress_handler(progress, 1)
00136         curs = con.cursor()
00137         curs.execute("""
00138             create table foo (a, b)
00139             """)
00140         first_count = len(progress_calls)
00141         progress_calls = []
00142         con.set_progress_handler(progress, 2)
00143         curs.execute("""
00144             create table bar (a, b)
00145             """)
00146         second_count = len(progress_calls)
00147         self.assertTrue(first_count > second_count)

Here is the call graph for this function:

Test that the progress handler is invoked once it is set.

Definition at line 109 of file hooks.py.

00109 
00110     def CheckProgressHandlerUsed(self):
00111         """
00112         Test that the progress handler is invoked once it is set.
00113         """
00114         con = sqlite.connect(":memory:")
00115         progress_calls = []
00116         def progress():
00117             progress_calls.append(None)
00118             return 0
00119         con.set_progress_handler(progress, 1)
00120         con.execute("""
00121             create table foo(a, b)
00122             """)
00123         self.assertTrue(progress_calls)
00124 

Here is the call graph for this function:


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