Mercurial > cpython-lru_cache-weakref
annotate Lib/sqlite3/test/types.py @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | ff040880d1be |
| children | 04d3ae52ff73 |
| rev | line source |
|---|---|
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
1 #-*- coding: ISO-8859-1 -*- |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
2 # pysqlite2/test/types.py: tests for type conversion and detection |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
3 # |
|
45580
b7ee9074ca0e
Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents:
44408
diff
changeset
|
4 # Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de> |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
5 # |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
6 # This file is part of pysqlite. |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
7 # |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
8 # This software is provided 'as-is', without any express or implied |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
9 # warranty. In no event will the authors be held liable for any damages |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
10 # arising from the use of this software. |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
11 # |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
12 # Permission is granted to anyone to use this software for any purpose, |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
13 # including commercial applications, and to alter it and redistribute it |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
14 # freely, subject to the following restrictions: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
15 # |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
16 # 1. The origin of this software must not be misrepresented; you must not |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
17 # claim that you wrote the original software. If you use this software |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
18 # in a product, an acknowledgment in the product documentation would be |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
19 # appreciated but is not required. |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
20 # 2. Altered source versions must be plainly marked as such, and must not be |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
21 # misrepresented as being the original software. |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
22 # 3. This notice may not be removed or altered from any source distribution. |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
23 |
|
55920
39be3ef82d23
#6026 - fix tests that failed without zlib
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55106
diff
changeset
|
24 import datetime |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
25 import unittest |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
26 import sqlite3 as sqlite |
|
55920
39be3ef82d23
#6026 - fix tests that failed without zlib
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55106
diff
changeset
|
27 try: |
|
39be3ef82d23
#6026 - fix tests that failed without zlib
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55106
diff
changeset
|
28 import zlib |
|
39be3ef82d23
#6026 - fix tests that failed without zlib
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55106
diff
changeset
|
29 except ImportError: |
|
39be3ef82d23
#6026 - fix tests that failed without zlib
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55106
diff
changeset
|
30 zlib = None |
|
39be3ef82d23
#6026 - fix tests that failed without zlib
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55106
diff
changeset
|
31 |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
32 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
33 class SqliteTypeTests(unittest.TestCase): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
34 def setUp(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
35 self.con = sqlite.connect(":memory:") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
36 self.cur = self.con.cursor() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
37 self.cur.execute("create table test(i integer, s varchar, f number, b blob)") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
38 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
39 def tearDown(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
40 self.cur.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
41 self.con.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
42 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
43 def CheckString(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
44 self.cur.execute("insert into test(s) values (?)", (u"Österreich",)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
45 self.cur.execute("select s from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
46 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
47 self.assertEqual(row[0], u"Österreich") |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
48 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
49 def CheckSmallInt(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
50 self.cur.execute("insert into test(i) values (?)", (42,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
51 self.cur.execute("select i from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
52 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
53 self.assertEqual(row[0], 42) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
54 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
55 def CheckLargeInt(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
56 num = 2**40 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
57 self.cur.execute("insert into test(i) values (?)", (num,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
58 self.cur.execute("select i from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
59 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
60 self.assertEqual(row[0], num) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
61 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
62 def CheckFloat(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
63 val = 3.14 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
64 self.cur.execute("insert into test(f) values (?)", (val,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
65 self.cur.execute("select f from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
66 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
67 self.assertEqual(row[0], val) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
68 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
69 def CheckBlob(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
70 val = buffer("Guglhupf") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
71 self.cur.execute("insert into test(b) values (?)", (val,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
72 self.cur.execute("select b from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
73 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
74 self.assertEqual(row[0], val) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
75 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
76 def CheckUnicodeExecute(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
77 self.cur.execute(u"select 'Österreich'") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
78 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
79 self.assertEqual(row[0], u"Österreich") |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
80 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
81 class DeclTypesTests(unittest.TestCase): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
82 class Foo: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
83 def __init__(self, _val): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
84 self.val = _val |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
85 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
86 def __cmp__(self, other): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
87 if not isinstance(other, DeclTypesTests.Foo): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
88 raise ValueError |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
89 if self.val == other.val: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
90 return 0 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
91 else: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
92 return 1 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
93 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
94 def __conform__(self, protocol): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
95 if protocol is sqlite.PrepareProtocol: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
96 return self.val |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
97 else: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
98 return None |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
99 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
100 def __str__(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
101 return "<%s>" % self.val |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
102 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
103 def setUp(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
104 self.con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
105 self.cur = self.con.cursor() |
|
46659
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
106 self.cur.execute("create table test(i int, s str, f float, b bool, u unicode, foo foo, bin blob, n1 number, n2 number(5))") |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
107 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
108 # override float, make them always return the same number |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
109 sqlite.converters["FLOAT"] = lambda x: 47.2 |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
110 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
111 # and implement two custom ones |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
112 sqlite.converters["BOOL"] = lambda x: bool(int(x)) |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
113 sqlite.converters["FOO"] = DeclTypesTests.Foo |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
114 sqlite.converters["WRONG"] = lambda x: "WRONG" |
|
46659
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
115 sqlite.converters["NUMBER"] = float |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
116 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
117 def tearDown(self): |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
118 del sqlite.converters["FLOAT"] |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
119 del sqlite.converters["BOOL"] |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
120 del sqlite.converters["FOO"] |
|
46659
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
121 del sqlite.converters["NUMBER"] |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
122 self.cur.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
123 self.con.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
124 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
125 def CheckString(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
126 # default |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
127 self.cur.execute("insert into test(s) values (?)", ("foo",)) |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
128 self.cur.execute('select s as "s [WRONG]" from test') |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
129 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
130 self.assertEqual(row[0], "foo") |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
131 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
132 def CheckSmallInt(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
133 # default |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
134 self.cur.execute("insert into test(i) values (?)", (42,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
135 self.cur.execute("select i from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
136 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
137 self.assertEqual(row[0], 42) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
138 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
139 def CheckLargeInt(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
140 # default |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
141 num = 2**40 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
142 self.cur.execute("insert into test(i) values (?)", (num,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
143 self.cur.execute("select i from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
144 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
145 self.assertEqual(row[0], num) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
146 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
147 def CheckFloat(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
148 # custom |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
149 val = 3.14 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
150 self.cur.execute("insert into test(f) values (?)", (val,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
151 self.cur.execute("select f from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
152 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
153 self.assertEqual(row[0], 47.2) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
154 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
155 def CheckBool(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
156 # custom |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
157 self.cur.execute("insert into test(b) values (?)", (False,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
158 self.cur.execute("select b from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
159 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
160 self.assertEqual(row[0], False) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
161 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
162 self.cur.execute("delete from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
163 self.cur.execute("insert into test(b) values (?)", (True,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
164 self.cur.execute("select b from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
165 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
166 self.assertEqual(row[0], True) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
167 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
168 def CheckUnicode(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
169 # default |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
170 val = u"\xd6sterreich" |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
171 self.cur.execute("insert into test(u) values (?)", (val,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
172 self.cur.execute("select u from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
173 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
174 self.assertEqual(row[0], val) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
175 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
176 def CheckFoo(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
177 val = DeclTypesTests.Foo("bla") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
178 self.cur.execute("insert into test(foo) values (?)", (val,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
179 self.cur.execute("select foo from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
180 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
181 self.assertEqual(row[0], val) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
182 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
183 def CheckUnsupportedSeq(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
184 class Bar: pass |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
185 val = Bar() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
186 try: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
187 self.cur.execute("insert into test(f) values (?)", (val,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
188 self.fail("should have raised an InterfaceError") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
189 except sqlite.InterfaceError: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
190 pass |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
191 except: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
192 self.fail("should have raised an InterfaceError") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
193 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
194 def CheckUnsupportedDict(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
195 class Bar: pass |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
196 val = Bar() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
197 try: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
198 self.cur.execute("insert into test(f) values (:val)", {"val": val}) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
199 self.fail("should have raised an InterfaceError") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
200 except sqlite.InterfaceError: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
201 pass |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
202 except: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
203 self.fail("should have raised an InterfaceError") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
204 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
205 def CheckBlob(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
206 # default |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
207 val = buffer("Guglhupf") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
208 self.cur.execute("insert into test(bin) values (?)", (val,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
209 self.cur.execute("select bin from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
210 row = self.cur.fetchone() |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
211 self.assertEqual(row[0], val) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
212 |
|
46659
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
213 def CheckNumber1(self): |
|
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
214 self.cur.execute("insert into test(n1) values (5)") |
|
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
215 value = self.cur.execute("select n1 from test").fetchone()[0] |
|
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
216 # if the converter is not used, it's an int instead of a float |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
217 self.assertEqual(type(value), float) |
|
46659
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
218 |
|
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
219 def CheckNumber2(self): |
|
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
220 """Checks wether converter names are cut off at '(' characters""" |
|
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
221 self.cur.execute("insert into test(n2) values (5)") |
|
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
222 value = self.cur.execute("select n2 from test").fetchone()[0] |
|
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
223 # if the converter is not used, it's an int instead of a float |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
224 self.assertEqual(type(value), float) |
|
46659
28b099ac4cd8
Implemented feature request 2157: Converter names are cut off at '('
Gerhard Häring <gh@ghaering.de>
parents:
45580
diff
changeset
|
225 |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
226 class ColNamesTests(unittest.TestCase): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
227 def setUp(self): |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
228 self.con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
229 self.cur = self.con.cursor() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
230 self.cur.execute("create table test(x foo)") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
231 |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
232 sqlite.converters["FOO"] = lambda x: "[%s]" % x |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
233 sqlite.converters["BAR"] = lambda x: "<%s>" % x |
|
58669
ff040880d1be
#7092: Silence more py3k warnings. Patch by Florent Xicluna.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55920
diff
changeset
|
234 sqlite.converters["EXC"] = lambda x: 5 // 0 |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
235 sqlite.converters["B1B1"] = lambda x: "MARKER" |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
236 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
237 def tearDown(self): |
|
38808
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
238 del sqlite.converters["FOO"] |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
239 del sqlite.converters["BAR"] |
|
3e5fd2b70e5a
Merged changes from external pysqlite 2.3.0 release. Documentation updates will
Gerhard Häring <gh@ghaering.de>
parents:
37362
diff
changeset
|
240 del sqlite.converters["EXC"] |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
241 del sqlite.converters["B1B1"] |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
242 self.cur.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
243 self.con.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
244 |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
245 def CheckDeclTypeNotUsed(self): |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
246 """ |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
247 Assures that the declared type is not used when PARSE_DECLTYPES |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
248 is not set. |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
249 """ |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
250 self.cur.execute("insert into test(x) values (?)", ("xxx",)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
251 self.cur.execute("select x from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
252 val = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
253 self.assertEqual(val, "xxx") |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
254 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
255 def CheckNone(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
256 self.cur.execute("insert into test(x) values (?)", (None,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
257 self.cur.execute("select x from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
258 val = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
259 self.assertEqual(val, None) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
260 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
261 def CheckColName(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
262 self.cur.execute("insert into test(x) values (?)", ("xxx",)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
263 self.cur.execute('select x as "x [bar]" from test') |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
264 val = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
265 self.assertEqual(val, "<xxx>") |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
266 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
267 # Check if the stripping of colnames works. Everything after the first |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
268 # whitespace should be stripped. |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
269 self.assertEqual(self.cur.description[0][0], "x") |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
270 |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
271 def CheckCaseInConverterName(self): |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
272 self.cur.execute("""select 'other' as "x [b1b1]\"""") |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
273 val = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
274 self.assertEqual(val, "MARKER") |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
275 |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
276 def CheckCursorDescriptionNoRow(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
277 """ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
278 cursor.description should at least provide the column name(s), even if |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
279 no row returned. |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
280 """ |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
281 self.cur.execute("select * from test where 0 = 1") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
282 self.assert_(self.cur.description[0][0] == "x") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
283 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
284 class ObjectAdaptationTests(unittest.TestCase): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
285 def cast(obj): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
286 return float(obj) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
287 cast = staticmethod(cast) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
288 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
289 def setUp(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
290 self.con = sqlite.connect(":memory:") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
291 try: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
292 del sqlite.adapters[int] |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
293 except: |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
294 pass |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
295 sqlite.register_adapter(int, ObjectAdaptationTests.cast) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
296 self.cur = self.con.cursor() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
297 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
298 def tearDown(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
299 del sqlite.adapters[(int, sqlite.PrepareProtocol)] |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
300 self.cur.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
301 self.con.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
302 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
303 def CheckCasterIsUsed(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
304 self.cur.execute("select ?", (4,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
305 val = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
306 self.assertEqual(type(val), float) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
307 |
|
55920
39be3ef82d23
#6026 - fix tests that failed without zlib
Ezio Melotti <ezio.melotti@gmail.com>
parents:
55106
diff
changeset
|
308 @unittest.skipUnless(zlib, "requires zlib") |
|
38978
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
309 class BinaryConverterTests(unittest.TestCase): |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
310 def convert(s): |
|
45580
b7ee9074ca0e
Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents:
44408
diff
changeset
|
311 return zlib.decompress(s) |
|
38978
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
312 convert = staticmethod(convert) |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
313 |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
314 def setUp(self): |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
315 self.con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES) |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
316 sqlite.register_converter("bin", BinaryConverterTests.convert) |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
317 |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
318 def tearDown(self): |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
319 self.con.close() |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
320 |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
321 def CheckBinaryInputForConverter(self): |
|
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
322 testdata = "abcdefg" * 10 |
|
45580
b7ee9074ca0e
Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents:
44408
diff
changeset
|
323 result = self.con.execute('select ? as "x [bin]"', (buffer(zlib.compress(testdata)),)).fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
324 self.assertEqual(testdata, result) |
|
38978
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
325 |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
326 class DateTimeTests(unittest.TestCase): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
327 def setUp(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
328 self.con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
329 self.cur = self.con.cursor() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
330 self.cur.execute("create table test(d date, ts timestamp)") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
331 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
332 def tearDown(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
333 self.cur.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
334 self.con.close() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
335 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
336 def CheckSqliteDate(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
337 d = sqlite.Date(2004, 2, 14) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
338 self.cur.execute("insert into test(d) values (?)", (d,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
339 self.cur.execute("select d from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
340 d2 = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
341 self.assertEqual(d, d2) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
342 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
343 def CheckSqliteTimestamp(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
344 ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
345 self.cur.execute("insert into test(ts) values (?)", (ts,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
346 self.cur.execute("select ts from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
347 ts2 = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
348 self.assertEqual(ts, ts2) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
349 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
350 def CheckSqlTimestamp(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
351 # The date functions are only available in SQLite version 3.1 or later |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
352 if sqlite.sqlite_version_info < (3, 1): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
353 return |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
354 |
|
45580
b7ee9074ca0e
Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents:
44408
diff
changeset
|
355 # SQLite's current_timestamp uses UTC time, while datetime.datetime.now() uses local time. |
|
b7ee9074ca0e
Updated to pysqlite 2.4.1. Documentation additions will come later.
Gerhard Häring <gh@ghaering.de>
parents:
44408
diff
changeset
|
356 now = datetime.datetime.now() |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
357 self.cur.execute("insert into test(ts) values (current_timestamp)") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
358 self.cur.execute("select ts from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
359 ts = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
360 self.assertEqual(type(ts), datetime.datetime) |
|
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
361 self.assertEqual(ts.year, now.year) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
362 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
363 def CheckDateTimeSubSeconds(self): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
364 ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0, 500000) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
365 self.cur.execute("insert into test(ts) values (?)", (ts,)) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
366 self.cur.execute("select ts from test") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
367 ts2 = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
368 self.assertEqual(ts, ts2) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
369 |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
370 def CheckDateTimeSubSecondsFloatingPoint(self): |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
371 ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0, 510241) |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
372 self.cur.execute("insert into test(ts) values (?)", (ts,)) |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
373 self.cur.execute("select ts from test") |
|
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
374 ts2 = self.cur.fetchone()[0] |
|
55106
7ff1405ccb64
Merge r73838 from py3k branch. Use the nondeprecated unittest method
Gregory P. Smith <greg@mad-scientist.com>
parents:
46659
diff
changeset
|
375 self.assertEqual(ts, ts2) |
|
40625
b9d4ced23506
Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents:
38978
diff
changeset
|
376 |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
377 def suite(): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
378 sqlite_type_suite = unittest.makeSuite(SqliteTypeTests, "Check") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
379 decltypes_type_suite = unittest.makeSuite(DeclTypesTests, "Check") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
380 colnames_type_suite = unittest.makeSuite(ColNamesTests, "Check") |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
381 adaptation_suite = unittest.makeSuite(ObjectAdaptationTests, "Check") |
|
38978
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
382 bin_suite = unittest.makeSuite(BinaryConverterTests, "Check") |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
383 date_suite = unittest.makeSuite(DateTimeTests, "Check") |
|
38978
5dd736268ff4
The sqlite3 module did cut off data from the SQLite database at the first null
Gerhard Häring <gh@ghaering.de>
parents:
38808
diff
changeset
|
384 return unittest.TestSuite((sqlite_type_suite, decltypes_type_suite, colnames_type_suite, adaptation_suite, bin_suite, date_suite)) |
|
37362
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
385 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
386 def test(): |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
387 runner = unittest.TextTestRunner() |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
388 runner.run(suite()) |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
389 |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
390 if __name__ == "__main__": |
|
e546274d6503
merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff
changeset
|
391 test() |
