Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
sqlite3.test.userfunctions.FunctionTests Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def CheckFuncErrorOnCreate
def CheckFuncRefCount
def CheckFuncReturnText
def CheckFuncReturnUnicode
def CheckFuncReturnInt
def CheckFuncReturnFloat
def CheckFuncReturnNull
def CheckFuncReturnBlob
def CheckFuncException
def CheckParamString
def CheckParamInt
def CheckParamFloat
def CheckParamNone
def CheckParamBlob

Public Attributes

 con

Detailed Description

Definition at line 120 of file userfunctions.py.


Member Function Documentation

Definition at line 141 of file userfunctions.py.

00141 
00142     def CheckFuncErrorOnCreate(self):
00143         try:
00144             self.con.create_function("bla", -100, lambda x: 2*x)
00145             self.fail("should have raised an OperationalError")
00146         except sqlite.OperationalError:
00147             pass

Here is the call graph for this function:

Definition at line 203 of file userfunctions.py.

00203 
00204     def CheckFuncException(self):
00205         cur = self.con.cursor()
00206         try:
00207             cur.execute("select raiseexception()")
00208             cur.fetchone()
00209             self.fail("should have raised OperationalError")
00210         except sqlite.OperationalError as e:
00211             self.assertEqual(e.args[0], 'user-defined function raised exception')

Here is the call graph for this function:

Definition at line 148 of file userfunctions.py.

00148 
00149     def CheckFuncRefCount(self):
00150         def getfunc():
00151             def f():
00152                 return 1
00153             return f
00154         f = getfunc()
00155         globals()["foo"] = f
00156         # self.con.create_function("reftest", 0, getfunc())
00157         self.con.create_function("reftest", 0, f)
00158         cur = self.con.cursor()
00159         cur.execute("select reftest()")

Definition at line 196 of file userfunctions.py.

00196 
00197     def CheckFuncReturnBlob(self):
00198         cur = self.con.cursor()
00199         cur.execute("select returnblob()")
00200         val = cur.fetchone()[0]
00201         self.assertEqual(type(val), bytes)
00202         self.assertEqual(val, b"blob")

Here is the call graph for this function:

Definition at line 181 of file userfunctions.py.

00181 
00182     def CheckFuncReturnFloat(self):
00183         cur = self.con.cursor()
00184         cur.execute("select returnfloat()")
00185         val = cur.fetchone()[0]
00186         self.assertEqual(type(val), float)
00187         if val < 3.139 or val > 3.141:
00188             self.fail("wrong value")

Here is the call graph for this function:

Definition at line 174 of file userfunctions.py.

00174 
00175     def CheckFuncReturnInt(self):
00176         cur = self.con.cursor()
00177         cur.execute("select returnint()")
00178         val = cur.fetchone()[0]
00179         self.assertEqual(type(val), int)
00180         self.assertEqual(val, 42)

Here is the call graph for this function:

Definition at line 189 of file userfunctions.py.

00189 
00190     def CheckFuncReturnNull(self):
00191         cur = self.con.cursor()
00192         cur.execute("select returnnull()")
00193         val = cur.fetchone()[0]
00194         self.assertEqual(type(val), type(None))
00195         self.assertEqual(val, None)

Here is the call graph for this function:

Definition at line 160 of file userfunctions.py.

00160 
00161     def CheckFuncReturnText(self):
00162         cur = self.con.cursor()
00163         cur.execute("select returntext()")
00164         val = cur.fetchone()[0]
00165         self.assertEqual(type(val), str)
00166         self.assertEqual(val, "foo")

Here is the call graph for this function:

Definition at line 167 of file userfunctions.py.

00167 
00168     def CheckFuncReturnUnicode(self):
00169         cur = self.con.cursor()
00170         cur.execute("select returnunicode()")
00171         val = cur.fetchone()[0]
00172         self.assertEqual(type(val), str)
00173         self.assertEqual(val, "bar")

Here is the call graph for this function:

Definition at line 236 of file userfunctions.py.

00236 
00237     def CheckParamBlob(self):
00238         cur = self.con.cursor()
00239         cur.execute("select isblob(?)", (memoryview(b"blob"),))
00240         val = cur.fetchone()[0]
00241         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 224 of file userfunctions.py.

00224 
00225     def CheckParamFloat(self):
00226         cur = self.con.cursor()
00227         cur.execute("select isfloat(?)", (3.14,))
00228         val = cur.fetchone()[0]
00229         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 218 of file userfunctions.py.

00218 
00219     def CheckParamInt(self):
00220         cur = self.con.cursor()
00221         cur.execute("select isint(?)", (42,))
00222         val = cur.fetchone()[0]
00223         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 230 of file userfunctions.py.

00230 
00231     def CheckParamNone(self):
00232         cur = self.con.cursor()
00233         cur.execute("select isnone(?)", (None,))
00234         val = cur.fetchone()[0]
00235         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 212 of file userfunctions.py.

00212 
00213     def CheckParamString(self):
00214         cur = self.con.cursor()
00215         cur.execute("select isstring(?)", ("foo",))
00216         val = cur.fetchone()[0]
00217         self.assertEqual(val, 1)

Here is the call graph for this function:

Definition at line 121 of file userfunctions.py.

00121 
00122     def setUp(self):
00123         self.con = sqlite.connect(":memory:")
00124 
00125         self.con.create_function("returntext", 0, func_returntext)
00126         self.con.create_function("returnunicode", 0, func_returnunicode)
00127         self.con.create_function("returnint", 0, func_returnint)
00128         self.con.create_function("returnfloat", 0, func_returnfloat)
00129         self.con.create_function("returnnull", 0, func_returnnull)
00130         self.con.create_function("returnblob", 0, func_returnblob)
00131         self.con.create_function("raiseexception", 0, func_raiseexception)
00132 
00133         self.con.create_function("isstring", 1, func_isstring)
00134         self.con.create_function("isint", 1, func_isint)
00135         self.con.create_function("isfloat", 1, func_isfloat)
00136         self.con.create_function("isnone", 1, func_isnone)
00137         self.con.create_function("isblob", 1, func_isblob)

Here is the caller graph for this function:

Definition at line 138 of file userfunctions.py.

00138 
00139     def tearDown(self):
00140         self.con.close()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 122 of file userfunctions.py.


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