~ubuntu-branches/ubuntu/precise/python3.2/precise-proposed

« back to all changes in this revision

Viewing changes to Lib/sqlite3/test/userfunctions.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-03-09 18:40:39 UTC
  • mfrom: (30.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120309184039-j3yk2emxr1plyo21
Tags: 3.2.3~rc1-1
* Python 3.2.3 release candidate 1.
* Update to 20120309 from the 3.2 branch.
* Fix libpython.a symlink. Closes: #660146.
* Build-depend on xauth.
* Run the gdb tests for the debug build only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    return None
38
38
def func_returnblob():
39
39
    return b"blob"
 
40
def func_returnlonglong():
 
41
    return 1<<31
40
42
def func_raiseexception():
41
43
    5/0
42
44
 
50
52
    return type(v) is type(None)
51
53
def func_isblob(v):
52
54
    return isinstance(v, (bytes, memoryview))
 
55
def func_islonglong(v):
 
56
    return isinstance(v, int) and v >= 1<<31
53
57
 
54
58
class AggrNoStep:
55
59
    def __init__(self):
127
131
        self.con.create_function("returnfloat", 0, func_returnfloat)
128
132
        self.con.create_function("returnnull", 0, func_returnnull)
129
133
        self.con.create_function("returnblob", 0, func_returnblob)
 
134
        self.con.create_function("returnlonglong", 0, func_returnlonglong)
130
135
        self.con.create_function("raiseexception", 0, func_raiseexception)
131
136
 
132
137
        self.con.create_function("isstring", 1, func_isstring)
134
139
        self.con.create_function("isfloat", 1, func_isfloat)
135
140
        self.con.create_function("isnone", 1, func_isnone)
136
141
        self.con.create_function("isblob", 1, func_isblob)
 
142
        self.con.create_function("islonglong", 1, func_islonglong)
137
143
 
138
144
    def tearDown(self):
139
145
        self.con.close()
200
206
        self.assertEqual(type(val), bytes)
201
207
        self.assertEqual(val, b"blob")
202
208
 
 
209
    def CheckFuncReturnLongLong(self):
 
210
        cur = self.con.cursor()
 
211
        cur.execute("select returnlonglong()")
 
212
        val = cur.fetchone()[0]
 
213
        self.assertEqual(val, 1<<31)
 
214
 
203
215
    def CheckFuncException(self):
204
216
        cur = self.con.cursor()
205
217
        try:
239
251
        val = cur.fetchone()[0]
240
252
        self.assertEqual(val, 1)
241
253
 
 
254
    def CheckParamLongLong(self):
 
255
        cur = self.con.cursor()
 
256
        cur.execute("select islonglong(?)", (1<<42,))
 
257
        val = cur.fetchone()[0]
 
258
        self.assertEqual(val, 1)
 
259
 
242
260
class AggregateTests(unittest.TestCase):
243
261
    def setUp(self):
244
262
        self.con = sqlite.connect(":memory:")