blob: 8a4bbab85caa7395b3f45a0ac5b82886571ab2b4 [file] [log] [blame]
Petri Lehtinenf8547992012-02-02 17:17:36 +02001#-*- coding: iso-8859-1 -*-
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00002# pysqlite2/test/userfunctions.py: tests for user-defined functions and
3# aggregates.
4#
Martin v. Löwis03117362008-03-30 20:21:00 +00005# Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00006#
7# This file is part of pysqlite.
8#
9# This software is provided 'as-is', without any express or implied
10# warranty. In no event will the authors be held liable for any damages
11# arising from the use of this software.
12#
13# Permission is granted to anyone to use this software for any purpose,
14# including commercial applications, and to alter it and redistribute it
15# freely, subject to the following restrictions:
16#
17# 1. The origin of this software must not be misrepresented; you must not
18# claim that you wrote the original software. If you use this software
19# in a product, an acknowledgment in the product documentation would be
20# appreciated but is not required.
21# 2. Altered source versions must be plainly marked as such, and must not be
22# misrepresented as being the original software.
23# 3. This notice may not be removed or altered from any source distribution.
24
25import unittest
26import sqlite3 as sqlite
27
28def func_returntext():
29 return "foo"
30def func_returnunicode():
Guido van Rossumef87d6e2007-05-02 19:09:54 +000031 return "bar"
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000032def func_returnint():
33 return 42
34def func_returnfloat():
35 return 3.14
36def func_returnnull():
37 return None
38def func_returnblob():
Guido van Rossumbae07c92007-10-08 02:46:15 +000039 return b"blob"
Petri Lehtinen4fe85ab2012-02-19 21:38:00 +020040def func_returnlonglong():
41 return 1<<31
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000042def func_raiseexception():
43 5/0
44
45def func_isstring(v):
Guido van Rossumef87d6e2007-05-02 19:09:54 +000046 return type(v) is str
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000047def func_isint(v):
48 return type(v) is int
49def func_isfloat(v):
50 return type(v) is float
51def func_isnone(v):
52 return type(v) is type(None)
53def func_isblob(v):
Guido van Rossumbae07c92007-10-08 02:46:15 +000054 return isinstance(v, (bytes, memoryview))
Petri Lehtinen4fe85ab2012-02-19 21:38:00 +020055def func_islonglong(v):
56 return isinstance(v, int) and v >= 1<<31
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000057
Berker Peksagfa0f62d2016-03-27 22:39:14 +030058def func(*args):
59 return len(args)
60
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000061class AggrNoStep:
62 def __init__(self):
63 pass
64
Thomas Wouters0e3f5912006-08-11 14:57:12 +000065 def finalize(self):
66 return 1
67
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000068class AggrNoFinalize:
69 def __init__(self):
70 pass
71
72 def step(self, x):
73 pass
74
75class AggrExceptionInInit:
76 def __init__(self):
77 5/0
78
79 def step(self, x):
80 pass
81
82 def finalize(self):
83 pass
84
85class AggrExceptionInStep:
86 def __init__(self):
87 pass
88
89 def step(self, x):
90 5/0
91
92 def finalize(self):
93 return 42
94
95class AggrExceptionInFinalize:
96 def __init__(self):
97 pass
98
99 def step(self, x):
100 pass
101
102 def finalize(self):
103 5/0
104
105class AggrCheckType:
106 def __init__(self):
107 self.val = None
108
109 def step(self, whichType, val):
Guido van Rossumbae07c92007-10-08 02:46:15 +0000110 theType = {"str": str, "int": int, "float": float, "None": type(None),
111 "blob": bytes}
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000112 self.val = int(theType[whichType] is type(val))
113
114 def finalize(self):
115 return self.val
116
Berker Peksagfa0f62d2016-03-27 22:39:14 +0300117class AggrCheckTypes:
118 def __init__(self):
119 self.val = 0
120
121 def step(self, whichType, *vals):
122 theType = {"str": str, "int": int, "float": float, "None": type(None),
123 "blob": bytes}
124 for val in vals:
125 self.val += int(theType[whichType] is type(val))
126
127 def finalize(self):
128 return self.val
129
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000130class AggrSum:
131 def __init__(self):
132 self.val = 0.0
133
134 def step(self, val):
135 self.val += val
136
137 def finalize(self):
138 return self.val
139
140class FunctionTests(unittest.TestCase):
141 def setUp(self):
142 self.con = sqlite.connect(":memory:")
143
144 self.con.create_function("returntext", 0, func_returntext)
145 self.con.create_function("returnunicode", 0, func_returnunicode)
146 self.con.create_function("returnint", 0, func_returnint)
147 self.con.create_function("returnfloat", 0, func_returnfloat)
148 self.con.create_function("returnnull", 0, func_returnnull)
149 self.con.create_function("returnblob", 0, func_returnblob)
Petri Lehtinen4fe85ab2012-02-19 21:38:00 +0200150 self.con.create_function("returnlonglong", 0, func_returnlonglong)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000151 self.con.create_function("raiseexception", 0, func_raiseexception)
152
153 self.con.create_function("isstring", 1, func_isstring)
154 self.con.create_function("isint", 1, func_isint)
155 self.con.create_function("isfloat", 1, func_isfloat)
156 self.con.create_function("isnone", 1, func_isnone)
157 self.con.create_function("isblob", 1, func_isblob)
Petri Lehtinen4fe85ab2012-02-19 21:38:00 +0200158 self.con.create_function("islonglong", 1, func_islonglong)
Berker Peksagfa0f62d2016-03-27 22:39:14 +0300159 self.con.create_function("spam", -1, func)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000160
161 def tearDown(self):
162 self.con.close()
163
Thomas Wouters477c8d52006-05-27 19:21:47 +0000164 def CheckFuncErrorOnCreate(self):
165 try:
166 self.con.create_function("bla", -100, lambda x: 2*x)
167 self.fail("should have raised an OperationalError")
168 except sqlite.OperationalError:
169 pass
170
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000171 def CheckFuncRefCount(self):
172 def getfunc():
173 def f():
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000174 return 1
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000175 return f
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000176 f = getfunc()
177 globals()["foo"] = f
178 # self.con.create_function("reftest", 0, getfunc())
179 self.con.create_function("reftest", 0, f)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000180 cur = self.con.cursor()
181 cur.execute("select reftest()")
182
183 def CheckFuncReturnText(self):
184 cur = self.con.cursor()
185 cur.execute("select returntext()")
186 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000187 self.assertEqual(type(val), str)
188 self.assertEqual(val, "foo")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000189
190 def CheckFuncReturnUnicode(self):
191 cur = self.con.cursor()
192 cur.execute("select returnunicode()")
193 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000194 self.assertEqual(type(val), str)
195 self.assertEqual(val, "bar")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000196
197 def CheckFuncReturnInt(self):
198 cur = self.con.cursor()
199 cur.execute("select returnint()")
200 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000201 self.assertEqual(type(val), int)
202 self.assertEqual(val, 42)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000203
204 def CheckFuncReturnFloat(self):
205 cur = self.con.cursor()
206 cur.execute("select returnfloat()")
207 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000208 self.assertEqual(type(val), float)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000209 if val < 3.139 or val > 3.141:
210 self.fail("wrong value")
211
212 def CheckFuncReturnNull(self):
213 cur = self.con.cursor()
214 cur.execute("select returnnull()")
215 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000216 self.assertEqual(type(val), type(None))
217 self.assertEqual(val, None)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000218
219 def CheckFuncReturnBlob(self):
220 cur = self.con.cursor()
221 cur.execute("select returnblob()")
222 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000223 self.assertEqual(type(val), bytes)
224 self.assertEqual(val, b"blob")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000225
Petri Lehtinen4fe85ab2012-02-19 21:38:00 +0200226 def CheckFuncReturnLongLong(self):
227 cur = self.con.cursor()
228 cur.execute("select returnlonglong()")
229 val = cur.fetchone()[0]
230 self.assertEqual(val, 1<<31)
231
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000232 def CheckFuncException(self):
233 cur = self.con.cursor()
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000234 try:
235 cur.execute("select raiseexception()")
236 cur.fetchone()
237 self.fail("should have raised OperationalError")
Guido van Rossumb940e112007-01-10 16:19:56 +0000238 except sqlite.OperationalError as e:
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000239 self.assertEqual(e.args[0], 'user-defined function raised exception')
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000240
241 def CheckParamString(self):
242 cur = self.con.cursor()
243 cur.execute("select isstring(?)", ("foo",))
244 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000245 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000246
247 def CheckParamInt(self):
248 cur = self.con.cursor()
249 cur.execute("select isint(?)", (42,))
250 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000251 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000252
253 def CheckParamFloat(self):
254 cur = self.con.cursor()
255 cur.execute("select isfloat(?)", (3.14,))
256 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000257 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000258
259 def CheckParamNone(self):
260 cur = self.con.cursor()
261 cur.execute("select isnone(?)", (None,))
262 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000263 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000264
265 def CheckParamBlob(self):
266 cur = self.con.cursor()
Guido van Rossumbae07c92007-10-08 02:46:15 +0000267 cur.execute("select isblob(?)", (memoryview(b"blob"),))
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000268 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000269 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000270
Petri Lehtinen4fe85ab2012-02-19 21:38:00 +0200271 def CheckParamLongLong(self):
272 cur = self.con.cursor()
273 cur.execute("select islonglong(?)", (1<<42,))
274 val = cur.fetchone()[0]
275 self.assertEqual(val, 1)
276
Berker Peksagfa0f62d2016-03-27 22:39:14 +0300277 def CheckAnyArguments(self):
278 cur = self.con.cursor()
279 cur.execute("select spam(?, ?)", (1, 2))
280 val = cur.fetchone()[0]
281 self.assertEqual(val, 2)
282
283
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000284class AggregateTests(unittest.TestCase):
285 def setUp(self):
286 self.con = sqlite.connect(":memory:")
287 cur = self.con.cursor()
288 cur.execute("""
289 create table test(
290 t text,
291 i integer,
292 f float,
293 n,
294 b blob
295 )
296 """)
297 cur.execute("insert into test(t, i, f, n, b) values (?, ?, ?, ?, ?)",
Guido van Rossumbae07c92007-10-08 02:46:15 +0000298 ("foo", 5, 3.14, None, memoryview(b"blob"),))
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000299
300 self.con.create_aggregate("nostep", 1, AggrNoStep)
301 self.con.create_aggregate("nofinalize", 1, AggrNoFinalize)
302 self.con.create_aggregate("excInit", 1, AggrExceptionInInit)
303 self.con.create_aggregate("excStep", 1, AggrExceptionInStep)
304 self.con.create_aggregate("excFinalize", 1, AggrExceptionInFinalize)
305 self.con.create_aggregate("checkType", 2, AggrCheckType)
Berker Peksagfa0f62d2016-03-27 22:39:14 +0300306 self.con.create_aggregate("checkTypes", -1, AggrCheckTypes)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000307 self.con.create_aggregate("mysum", 1, AggrSum)
308
309 def tearDown(self):
310 #self.cur.close()
311 #self.con.close()
312 pass
313
Thomas Wouters477c8d52006-05-27 19:21:47 +0000314 def CheckAggrErrorOnCreate(self):
315 try:
316 self.con.create_function("bla", -100, AggrSum)
317 self.fail("should have raised an OperationalError")
318 except sqlite.OperationalError:
319 pass
320
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000321 def CheckAggrNoStep(self):
322 cur = self.con.cursor()
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000323 try:
324 cur.execute("select nostep(t) from test")
325 self.fail("should have raised an AttributeError")
Guido van Rossumb940e112007-01-10 16:19:56 +0000326 except AttributeError as e:
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000327 self.assertEqual(e.args[0], "'AggrNoStep' object has no attribute 'step'")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000328
329 def CheckAggrNoFinalize(self):
330 cur = self.con.cursor()
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000331 try:
332 cur.execute("select nofinalize(t) from test")
333 val = cur.fetchone()[0]
334 self.fail("should have raised an OperationalError")
Guido van Rossumb940e112007-01-10 16:19:56 +0000335 except sqlite.OperationalError as e:
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000336 self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000337
338 def CheckAggrExceptionInInit(self):
339 cur = self.con.cursor()
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000340 try:
341 cur.execute("select excInit(t) from test")
342 val = cur.fetchone()[0]
343 self.fail("should have raised an OperationalError")
Guido van Rossumb940e112007-01-10 16:19:56 +0000344 except sqlite.OperationalError as e:
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000345 self.assertEqual(e.args[0], "user-defined aggregate's '__init__' method raised error")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000346
347 def CheckAggrExceptionInStep(self):
348 cur = self.con.cursor()
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000349 try:
350 cur.execute("select excStep(t) from test")
351 val = cur.fetchone()[0]
352 self.fail("should have raised an OperationalError")
Guido van Rossumb940e112007-01-10 16:19:56 +0000353 except sqlite.OperationalError as e:
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000354 self.assertEqual(e.args[0], "user-defined aggregate's 'step' method raised error")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000355
356 def CheckAggrExceptionInFinalize(self):
357 cur = self.con.cursor()
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000358 try:
359 cur.execute("select excFinalize(t) from test")
360 val = cur.fetchone()[0]
361 self.fail("should have raised an OperationalError")
Guido van Rossumb940e112007-01-10 16:19:56 +0000362 except sqlite.OperationalError as e:
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000363 self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000364
365 def CheckAggrCheckParamStr(self):
366 cur = self.con.cursor()
367 cur.execute("select checkType('str', ?)", ("foo",))
368 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000369 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000370
371 def CheckAggrCheckParamInt(self):
372 cur = self.con.cursor()
373 cur.execute("select checkType('int', ?)", (42,))
374 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000375 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000376
Berker Peksagfa0f62d2016-03-27 22:39:14 +0300377 def CheckAggrCheckParamsInt(self):
378 cur = self.con.cursor()
379 cur.execute("select checkTypes('int', ?, ?)", (42, 24))
380 val = cur.fetchone()[0]
381 self.assertEqual(val, 2)
382
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000383 def CheckAggrCheckParamFloat(self):
384 cur = self.con.cursor()
385 cur.execute("select checkType('float', ?)", (3.14,))
386 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000387 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000388
389 def CheckAggrCheckParamNone(self):
390 cur = self.con.cursor()
391 cur.execute("select checkType('None', ?)", (None,))
392 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000393 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000394
395 def CheckAggrCheckParamBlob(self):
396 cur = self.con.cursor()
Guido van Rossumbae07c92007-10-08 02:46:15 +0000397 cur.execute("select checkType('blob', ?)", (memoryview(b"blob"),))
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000398 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000399 self.assertEqual(val, 1)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000400
401 def CheckAggrCheckAggrSum(self):
402 cur = self.con.cursor()
403 cur.execute("delete from test")
404 cur.executemany("insert into test(i) values (?)", [(10,), (20,), (30,)])
405 cur.execute("select mysum(i) from test")
406 val = cur.fetchone()[0]
Gregory P. Smith04cecaf2009-07-04 08:32:15 +0000407 self.assertEqual(val, 60)
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000408
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000409class AuthorizerTests(unittest.TestCase):
Serhiy Storchaka3cf96ac2013-02-07 17:01:47 +0200410 @staticmethod
411 def authorizer_cb(action, arg1, arg2, dbname, source):
412 if action != sqlite.SQLITE_SELECT:
413 return sqlite.SQLITE_DENY
414 if arg2 == 'c2' or arg1 == 't2':
415 return sqlite.SQLITE_DENY
416 return sqlite.SQLITE_OK
417
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000418 def setUp(self):
419 self.con = sqlite.connect(":memory:")
420 self.con.executescript("""
421 create table t1 (c1, c2);
422 create table t2 (c1, c2);
423 insert into t1 (c1, c2) values (1, 2);
424 insert into t2 (c1, c2) values (4, 5);
425 """)
426
427 # For our security test:
428 self.con.execute("select c2 from t2")
429
Serhiy Storchaka3cf96ac2013-02-07 17:01:47 +0200430 self.con.set_authorizer(self.authorizer_cb)
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000431
432 def tearDown(self):
433 pass
434
Serhiy Storchaka3cf96ac2013-02-07 17:01:47 +0200435 def test_table_access(self):
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000436 try:
437 self.con.execute("select * from t2")
Guido van Rossumb940e112007-01-10 16:19:56 +0000438 except sqlite.DatabaseError as e:
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000439 if not e.args[0].endswith("prohibited"):
440 self.fail("wrong exception text: %s" % e.args[0])
441 return
442 self.fail("should have raised an exception due to missing privileges")
443
Serhiy Storchaka3cf96ac2013-02-07 17:01:47 +0200444 def test_column_access(self):
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000445 try:
446 self.con.execute("select c2 from t1")
Guido van Rossumb940e112007-01-10 16:19:56 +0000447 except sqlite.DatabaseError as e:
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000448 if not e.args[0].endswith("prohibited"):
449 self.fail("wrong exception text: %s" % e.args[0])
450 return
451 self.fail("should have raised an exception due to missing privileges")
452
Serhiy Storchaka3cf96ac2013-02-07 17:01:47 +0200453class AuthorizerRaiseExceptionTests(AuthorizerTests):
454 @staticmethod
455 def authorizer_cb(action, arg1, arg2, dbname, source):
456 if action != sqlite.SQLITE_SELECT:
457 raise ValueError
458 if arg2 == 'c2' or arg1 == 't2':
459 raise ValueError
460 return sqlite.SQLITE_OK
461
462class AuthorizerIllegalTypeTests(AuthorizerTests):
463 @staticmethod
464 def authorizer_cb(action, arg1, arg2, dbname, source):
465 if action != sqlite.SQLITE_SELECT:
466 return 0.0
467 if arg2 == 'c2' or arg1 == 't2':
468 return 0.0
469 return sqlite.SQLITE_OK
470
471class AuthorizerLargeIntegerTests(AuthorizerTests):
472 @staticmethod
473 def authorizer_cb(action, arg1, arg2, dbname, source):
474 if action != sqlite.SQLITE_SELECT:
475 return 2**32
476 if arg2 == 'c2' or arg1 == 't2':
477 return 2**32
478 return sqlite.SQLITE_OK
479
480
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000481def suite():
482 function_suite = unittest.makeSuite(FunctionTests, "Check")
483 aggregate_suite = unittest.makeSuite(AggregateTests, "Check")
Serhiy Storchaka3cf96ac2013-02-07 17:01:47 +0200484 authorizer_suite = unittest.makeSuite(AuthorizerTests)
485 return unittest.TestSuite((
486 function_suite,
487 aggregate_suite,
488 authorizer_suite,
489 unittest.makeSuite(AuthorizerRaiseExceptionTests),
490 unittest.makeSuite(AuthorizerIllegalTypeTests),
491 unittest.makeSuite(AuthorizerLargeIntegerTests),
492 ))
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000493
494def test():
495 runner = unittest.TextTestRunner()
496 runner.run(suite())
497
498if __name__ == "__main__":
499 test()