summaryrefslogtreecommitdiffstats
path: root/Lib/sqlite3/test/userfunctions.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/sqlite3/test/userfunctions.py')
-rw-r--r--Lib/sqlite3/test/userfunctions.py90
1 files changed, 45 insertions, 45 deletions
diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py
index c11c82e..2285abd 100644
--- a/Lib/sqlite3/test/userfunctions.py
+++ b/Lib/sqlite3/test/userfunctions.py
@@ -162,11 +162,11 @@ class FunctionTests(unittest.TestCase):
def tearDown(self):
self.con.close()
- def CheckFuncErrorOnCreate(self):
+ def test_func_error_on_create(self):
with self.assertRaises(sqlite.OperationalError):
self.con.create_function("bla", -100, lambda x: 2*x)
- def CheckFuncRefCount(self):
+ def test_func_ref_count(self):
def getfunc():
def f():
return 1
@@ -178,28 +178,28 @@ class FunctionTests(unittest.TestCase):
cur = self.con.cursor()
cur.execute("select reftest()")
- def CheckFuncReturnText(self):
+ def test_func_return_text(self):
cur = self.con.cursor()
cur.execute("select returntext()")
val = cur.fetchone()[0]
self.assertEqual(type(val), str)
self.assertEqual(val, "foo")
- def CheckFuncReturnUnicode(self):
+ def test_func_return_unicode(self):
cur = self.con.cursor()
cur.execute("select returnunicode()")
val = cur.fetchone()[0]
self.assertEqual(type(val), str)
self.assertEqual(val, "bar")
- def CheckFuncReturnInt(self):
+ def test_func_return_int(self):
cur = self.con.cursor()
cur.execute("select returnint()")
val = cur.fetchone()[0]
self.assertEqual(type(val), int)
self.assertEqual(val, 42)
- def CheckFuncReturnFloat(self):
+ def test_func_return_float(self):
cur = self.con.cursor()
cur.execute("select returnfloat()")
val = cur.fetchone()[0]
@@ -207,70 +207,70 @@ class FunctionTests(unittest.TestCase):
if val < 3.139 or val > 3.141:
self.fail("wrong value")
- def CheckFuncReturnNull(self):
+ def test_func_return_null(self):
cur = self.con.cursor()
cur.execute("select returnnull()")
val = cur.fetchone()[0]
self.assertEqual(type(val), type(None))
self.assertEqual(val, None)
- def CheckFuncReturnBlob(self):
+ def test_func_return_blob(self):
cur = self.con.cursor()
cur.execute("select returnblob()")
val = cur.fetchone()[0]
self.assertEqual(type(val), bytes)
self.assertEqual(val, b"blob")
- def CheckFuncReturnLongLong(self):
+ def test_func_return_long_long(self):
cur = self.con.cursor()
cur.execute("select returnlonglong()")
val = cur.fetchone()[0]
self.assertEqual(val, 1<<31)
- def CheckFuncException(self):
+ def test_func_exception(self):
cur = self.con.cursor()
with self.assertRaises(sqlite.OperationalError) as cm:
cur.execute("select raiseexception()")
cur.fetchone()
self.assertEqual(str(cm.exception), 'user-defined function raised exception')
- def CheckParamString(self):
+ def test_param_string(self):
cur = self.con.cursor()
cur.execute("select isstring(?)", ("foo",))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckParamInt(self):
+ def test_param_int(self):
cur = self.con.cursor()
cur.execute("select isint(?)", (42,))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckParamFloat(self):
+ def test_param_float(self):
cur = self.con.cursor()
cur.execute("select isfloat(?)", (3.14,))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckParamNone(self):
+ def test_param_none(self):
cur = self.con.cursor()
cur.execute("select isnone(?)", (None,))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckParamBlob(self):
+ def test_param_blob(self):
cur = self.con.cursor()
cur.execute("select isblob(?)", (memoryview(b"blob"),))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckParamLongLong(self):
+ def test_param_long_long(self):
cur = self.con.cursor()
cur.execute("select islonglong(?)", (1<<42,))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckAnyArguments(self):
+ def test_any_arguments(self):
cur = self.con.cursor()
cur.execute("select spam(?, ?)", (1, 2))
val = cur.fetchone()[0]
@@ -284,7 +284,7 @@ class FunctionTests(unittest.TestCase):
# deterministic functions were permitted in WHERE clauses of partial
# indices, which allows testing based on syntax, iso. the query optimizer.
@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "Requires SQLite 3.8.3 or higher")
- def CheckFuncNonDeterministic(self):
+ def test_func_non_deterministic(self):
mock = unittest.mock.Mock(return_value=None)
self.con.create_function("nondeterministic", 0, mock, deterministic=False)
if sqlite.sqlite_version_info < (3, 15, 0):
@@ -295,7 +295,7 @@ class FunctionTests(unittest.TestCase):
self.con.execute("create index t on test(t) where nondeterministic() is not null")
@unittest.skipIf(sqlite.sqlite_version_info < (3, 8, 3), "Requires SQLite 3.8.3 or higher")
- def CheckFuncDeterministic(self):
+ def test_func_deterministic(self):
mock = unittest.mock.Mock(return_value=None)
self.con.create_function("deterministic", 0, mock, deterministic=True)
if sqlite.sqlite_version_info < (3, 15, 0):
@@ -308,11 +308,11 @@ class FunctionTests(unittest.TestCase):
self.fail("Unexpected failure while creating partial index")
@unittest.skipIf(sqlite.sqlite_version_info >= (3, 8, 3), "SQLite < 3.8.3 needed")
- def CheckFuncDeterministicNotSupported(self):
+ def test_func_deterministic_not_supported(self):
with self.assertRaises(sqlite.NotSupportedError):
self.con.create_function("deterministic", 0, int, deterministic=True)
- def CheckFuncDeterministicKeywordOnly(self):
+ def test_func_deterministic_keyword_only(self):
with self.assertRaises(TypeError):
self.con.create_function("deterministic", 0, int, True)
@@ -347,81 +347,81 @@ class AggregateTests(unittest.TestCase):
#self.con.close()
pass
- def CheckAggrErrorOnCreate(self):
+ def test_aggr_error_on_create(self):
with self.assertRaises(sqlite.OperationalError):
self.con.create_function("bla", -100, AggrSum)
- def CheckAggrNoStep(self):
+ def test_aggr_no_step(self):
cur = self.con.cursor()
with self.assertRaises(AttributeError) as cm:
cur.execute("select nostep(t) from test")
self.assertEqual(str(cm.exception), "'AggrNoStep' object has no attribute 'step'")
- def CheckAggrNoFinalize(self):
+ def test_aggr_no_finalize(self):
cur = self.con.cursor()
with self.assertRaises(sqlite.OperationalError) as cm:
cur.execute("select nofinalize(t) from test")
val = cur.fetchone()[0]
self.assertEqual(str(cm.exception), "user-defined aggregate's 'finalize' method raised error")
- def CheckAggrExceptionInInit(self):
+ def test_aggr_exception_in_init(self):
cur = self.con.cursor()
with self.assertRaises(sqlite.OperationalError) as cm:
cur.execute("select excInit(t) from test")
val = cur.fetchone()[0]
self.assertEqual(str(cm.exception), "user-defined aggregate's '__init__' method raised error")
- def CheckAggrExceptionInStep(self):
+ def test_aggr_exception_in_step(self):
cur = self.con.cursor()
with self.assertRaises(sqlite.OperationalError) as cm:
cur.execute("select excStep(t) from test")
val = cur.fetchone()[0]
self.assertEqual(str(cm.exception), "user-defined aggregate's 'step' method raised error")
- def CheckAggrExceptionInFinalize(self):
+ def test_aggr_exception_in_finalize(self):
cur = self.con.cursor()
with self.assertRaises(sqlite.OperationalError) as cm:
cur.execute("select excFinalize(t) from test")
val = cur.fetchone()[0]
self.assertEqual(str(cm.exception), "user-defined aggregate's 'finalize' method raised error")
- def CheckAggrCheckParamStr(self):
+ def test_aggr_check_param_str(self):
cur = self.con.cursor()
cur.execute("select checkType('str', ?)", ("foo",))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckAggrCheckParamInt(self):
+ def test_aggr_check_param_int(self):
cur = self.con.cursor()
cur.execute("select checkType('int', ?)", (42,))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckAggrCheckParamsInt(self):
+ def test_aggr_check_params_int(self):
cur = self.con.cursor()
cur.execute("select checkTypes('int', ?, ?)", (42, 24))
val = cur.fetchone()[0]
self.assertEqual(val, 2)
- def CheckAggrCheckParamFloat(self):
+ def test_aggr_check_param_float(self):
cur = self.con.cursor()
cur.execute("select checkType('float', ?)", (3.14,))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckAggrCheckParamNone(self):
+ def test_aggr_check_param_none(self):
cur = self.con.cursor()
cur.execute("select checkType('None', ?)", (None,))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckAggrCheckParamBlob(self):
+ def test_aggr_check_param_blob(self):
cur = self.con.cursor()
cur.execute("select checkType('blob', ?)", (memoryview(b"blob"),))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
- def CheckAggrCheckAggrSum(self):
+ def test_aggr_check_aggr_sum(self):
cur = self.con.cursor()
cur.execute("delete from test")
cur.executemany("insert into test(i) values (?)", [(10,), (20,), (30,)])
@@ -494,17 +494,17 @@ class AuthorizerLargeIntegerTests(AuthorizerTests):
def suite():
- function_suite = unittest.makeSuite(FunctionTests, "Check")
- aggregate_suite = unittest.makeSuite(AggregateTests, "Check")
- authorizer_suite = unittest.makeSuite(AuthorizerTests)
- return unittest.TestSuite((
- function_suite,
- aggregate_suite,
- authorizer_suite,
- unittest.makeSuite(AuthorizerRaiseExceptionTests),
- unittest.makeSuite(AuthorizerIllegalTypeTests),
- unittest.makeSuite(AuthorizerLargeIntegerTests),
- ))
+ tests = [
+ AggregateTests,
+ AuthorizerIllegalTypeTests,
+ AuthorizerLargeIntegerTests,
+ AuthorizerRaiseExceptionTests,
+ AuthorizerTests,
+ FunctionTests,
+ ]
+ return unittest.TestSuite(
+ [unittest.TestLoader().loadTestsFromTestCase(t) for t in tests]
+ )
def test():
runner = unittest.TextTestRunner()