summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3/test/userfunctions.py
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2012-02-21 11:59:34 (GMT)
committerPetri Lehtinen <petri@digip.org>2012-02-21 11:59:40 (GMT)
commit8b24506534860b6c1cfa7f53c40113d502f4c78f (patch)
tree6ee951cd4c9865f21a3323be82ff94bb18a8b727 /Lib/sqlite3/test/userfunctions.py
parent307da2b07040d0eea179cf989e3de8d9e75a9b2f (diff)
parent4fe85abab9f0188733e654a72353217b43f95920 (diff)
downloadcpython-8b24506534860b6c1cfa7f53c40113d502f4c78f.zip
cpython-8b24506534860b6c1cfa7f53c40113d502f4c78f.tar.gz
cpython-8b24506534860b6c1cfa7f53c40113d502f4c78f.tar.bz2
Merge branch '3.2'
Closes #8033.
Diffstat (limited to 'Lib/sqlite3/test/userfunctions.py')
-rw-r--r--Lib/sqlite3/test/userfunctions.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py
index 0541e25..14f6b65 100644
--- a/Lib/sqlite3/test/userfunctions.py
+++ b/Lib/sqlite3/test/userfunctions.py
@@ -37,6 +37,8 @@ def func_returnnull():
return None
def func_returnblob():
return b"blob"
+def func_returnlonglong():
+ return 1<<31
def func_raiseexception():
5/0
@@ -50,6 +52,8 @@ def func_isnone(v):
return type(v) is type(None)
def func_isblob(v):
return isinstance(v, (bytes, memoryview))
+def func_islonglong(v):
+ return isinstance(v, int) and v >= 1<<31
class AggrNoStep:
def __init__(self):
@@ -127,6 +131,7 @@ class FunctionTests(unittest.TestCase):
self.con.create_function("returnfloat", 0, func_returnfloat)
self.con.create_function("returnnull", 0, func_returnnull)
self.con.create_function("returnblob", 0, func_returnblob)
+ self.con.create_function("returnlonglong", 0, func_returnlonglong)
self.con.create_function("raiseexception", 0, func_raiseexception)
self.con.create_function("isstring", 1, func_isstring)
@@ -134,6 +139,7 @@ class FunctionTests(unittest.TestCase):
self.con.create_function("isfloat", 1, func_isfloat)
self.con.create_function("isnone", 1, func_isnone)
self.con.create_function("isblob", 1, func_isblob)
+ self.con.create_function("islonglong", 1, func_islonglong)
def tearDown(self):
self.con.close()
@@ -200,6 +206,12 @@ class FunctionTests(unittest.TestCase):
self.assertEqual(type(val), bytes)
self.assertEqual(val, b"blob")
+ def CheckFuncReturnLongLong(self):
+ cur = self.con.cursor()
+ cur.execute("select returnlonglong()")
+ val = cur.fetchone()[0]
+ self.assertEqual(val, 1<<31)
+
def CheckFuncException(self):
cur = self.con.cursor()
try:
@@ -239,6 +251,12 @@ class FunctionTests(unittest.TestCase):
val = cur.fetchone()[0]
self.assertEqual(val, 1)
+ def CheckParamLongLong(self):
+ cur = self.con.cursor()
+ cur.execute("select islonglong(?)", (1<<42,))
+ val = cur.fetchone()[0]
+ self.assertEqual(val, 1)
+
class AggregateTests(unittest.TestCase):
def setUp(self):
self.con = sqlite.connect(":memory:")