Mercurial > cpython-lru_cache-weakref
annotate Lib/sqlite3/test/hooks.py @ 79691:05c8928362ee
Merge __next__ method link fixes with 3.3.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Fri, 12 Oct 2012 13:46:37 +0300 |
| parents | 6b834e3c0882 |
| children | cdf9142a0c84 |
| rev | line source |
|---|---|
|
74726
d2ab2e4ce3ae
Make sqlite3 tests editable with Emacs
Petri Lehtinen <petri@digip.org>
parents:
69124
diff
changeset
|
1 #-*- coding: iso-8859-1 -*- |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2 # pysqlite2/test/hooks.py: tests for various SQLite-specific hooks |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
3 # |
|
46178
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
4 # Copyright (C) 2006-2007 Gerhard Häring <gh@ghaering.de> |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
5 # |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
6 # This file is part of pysqlite. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
7 # |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
8 # This software is provided 'as-is', without any express or implied |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
9 # warranty. In no event will the authors be held liable for any damages |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
10 # arising from the use of this software. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
11 # |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
12 # Permission is granted to anyone to use this software for any purpose, |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
13 # including commercial applications, and to alter it and redistribute it |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
14 # freely, subject to the following restrictions: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
15 # |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
16 # 1. The origin of this software must not be misrepresented; you must not |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
17 # claim that you wrote the original software. If you use this software |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
18 # in a product, an acknowledgment in the product documentation would be |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
19 # appreciated but is not required. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
20 # 2. Altered source versions must be plainly marked as such, and must not be |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
21 # misrepresented as being the original software. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
22 # 3. This notice may not be removed or altered from any source distribution. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
23 |
|
45471
7dd2c1746267
Merged revisions 60990-61002 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents:
40587
diff
changeset
|
24 import unittest |
|
38453
29ae5e0fc348
Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents:
37879
diff
changeset
|
25 import sqlite3 as sqlite |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
26 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
27 class CollationTests(unittest.TestCase): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
28 def setUp(self): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
29 pass |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
30 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
31 def tearDown(self): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
32 pass |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
33 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
34 def CheckCreateCollationNotCallable(self): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
35 con = sqlite.connect(":memory:") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
36 try: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
37 con.create_collation("X", 42) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
38 self.fail("should have raised a TypeError") |
|
40587
6b18a095c2e7
SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
39 except TypeError as e: |
|
55602
680ad8eed33b
Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51122
diff
changeset
|
40 self.assertEqual(e.args[0], "parameter must be callable") |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
41 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
42 def CheckCreateCollationNotAscii(self): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
43 con = sqlite.connect(":memory:") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
44 try: |
|
51122
adbd77a90bde
Merged revisions 69025 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
46178
diff
changeset
|
45 con.create_collation("collä", lambda x, y: (x > y) - (x < y)) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
46 self.fail("should have raised a ProgrammingError") |
|
40587
6b18a095c2e7
SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
47 except sqlite.ProgrammingError as e: |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
48 pass |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
49 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
50 def CheckCollationIsUsed(self): |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
51 if sqlite.version_info < (3, 2, 1): # old SQLite versions crash on this test |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
52 return |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
53 def mycoll(x, y): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
54 # reverse order |
|
51122
adbd77a90bde
Merged revisions 69025 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
46178
diff
changeset
|
55 return -((x > y) - (x < y)) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
56 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
57 con = sqlite.connect(":memory:") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
58 con.create_collation("mycoll", mycoll) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
59 sql = """ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
60 select x from ( |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
61 select 'a' as x |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
62 union |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
63 select 'b' as x |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
64 union |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
65 select 'c' as x |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
66 ) order by x collate mycoll |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
67 """ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
68 result = con.execute(sql).fetchall() |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
69 if result[0][0] != "c" or result[1][0] != "b" or result[2][0] != "a": |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
70 self.fail("the expected order was not returned") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
71 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
72 con.create_collation("mycoll", None) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
73 try: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
74 result = con.execute(sql).fetchall() |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
75 self.fail("should have raised an OperationalError") |
|
40587
6b18a095c2e7
SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
76 except sqlite.OperationalError as e: |
|
55602
680ad8eed33b
Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51122
diff
changeset
|
77 self.assertEqual(e.args[0].lower(), "no such collation sequence: mycoll") |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
78 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
79 def CheckCollationRegisterTwice(self): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
80 """ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
81 Register two different collation functions under the same name. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
82 Verify that the last one is actually used. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
83 """ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
84 con = sqlite.connect(":memory:") |
|
51122
adbd77a90bde
Merged revisions 69025 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
46178
diff
changeset
|
85 con.create_collation("mycoll", lambda x, y: (x > y) - (x < y)) |
|
adbd77a90bde
Merged revisions 69025 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
46178
diff
changeset
|
86 con.create_collation("mycoll", lambda x, y: -((x > y) - (x < y))) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
87 result = con.execute(""" |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
88 select x from (select 'a' as x union select 'b' as x) order by x collate mycoll |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
89 """).fetchall() |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
90 if result[0][0] != 'b' or result[1][0] != 'a': |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
91 self.fail("wrong collation function is used") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
92 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
93 def CheckDeregisterCollation(self): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
94 """ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
95 Register a collation, then deregister it. Make sure an error is raised if we try |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
96 to use it. |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
97 """ |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
98 con = sqlite.connect(":memory:") |
|
51122
adbd77a90bde
Merged revisions 69025 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents:
46178
diff
changeset
|
99 con.create_collation("mycoll", lambda x, y: (x > y) - (x < y)) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
100 con.create_collation("mycoll", None) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
101 try: |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
102 con.execute("select 'a' as x union select 'b' as x order by x collate mycoll") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
103 self.fail("should have raised an OperationalError") |
|
40587
6b18a095c2e7
SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents:
39442
diff
changeset
|
104 except sqlite.OperationalError as e: |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
105 if not e.args[0].startswith("no such collation sequence"): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
106 self.fail("wrong OperationalError raised") |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
107 |
|
46178
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
108 class ProgressTests(unittest.TestCase): |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
109 def CheckProgressHandlerUsed(self): |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
110 """ |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
111 Test that the progress handler is invoked once it is set. |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
112 """ |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
113 con = sqlite.connect(":memory:") |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
114 progress_calls = [] |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
115 def progress(): |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
116 progress_calls.append(None) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
117 return 0 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
118 con.set_progress_handler(progress, 1) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
119 con.execute(""" |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
120 create table foo(a, b) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
121 """) |
|
55602
680ad8eed33b
Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51122
diff
changeset
|
122 self.assertTrue(progress_calls) |
|
46178
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
123 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
124 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
125 def CheckOpcodeCount(self): |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
126 """ |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
127 Test that the opcode argument is respected. |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
128 """ |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
129 con = sqlite.connect(":memory:") |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
130 progress_calls = [] |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
131 def progress(): |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
132 progress_calls.append(None) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
133 return 0 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
134 con.set_progress_handler(progress, 1) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
135 curs = con.cursor() |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
136 curs.execute(""" |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
137 create table foo (a, b) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
138 """) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
139 first_count = len(progress_calls) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
140 progress_calls = [] |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
141 con.set_progress_handler(progress, 2) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
142 curs.execute(""" |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
143 create table bar (a, b) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
144 """) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
145 second_count = len(progress_calls) |
|
55602
680ad8eed33b
Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51122
diff
changeset
|
146 self.assertTrue(first_count > second_count) |
|
46178
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
147 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
148 def CheckCancelOperation(self): |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
149 """ |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
150 Test that returning a non-zero value stops the operation in progress. |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
151 """ |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
152 con = sqlite.connect(":memory:") |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
153 progress_calls = [] |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
154 def progress(): |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
155 progress_calls.append(None) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
156 return 1 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
157 con.set_progress_handler(progress, 1) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
158 curs = con.cursor() |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
159 self.assertRaises( |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
160 sqlite.OperationalError, |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
161 curs.execute, |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
162 "create table bar (a, b)") |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
163 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
164 def CheckClearHandler(self): |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
165 """ |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
166 Test that setting the progress handler to None clears the previously set handler. |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
167 """ |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
168 con = sqlite.connect(":memory:") |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
169 action = 0 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
170 def progress(): |
|
75006
bf7226719aec
Fix a variable scoping error in an sqlite3 test
Petri Lehtinen <petri@digip.org>
parents:
55602
diff
changeset
|
171 nonlocal action |
|
46178
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
172 action = 1 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
173 return 0 |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
174 con.set_progress_handler(progress, 1) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
175 con.set_progress_handler(None, 1) |
|
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
176 con.execute("select 1 union select 2 union select 3").fetchall() |
|
55602
680ad8eed33b
Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents:
51122
diff
changeset
|
177 self.assertEqual(action, 0, "progress handler was not cleared") |
|
46178
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
178 |
|
69120
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
179 class TraceCallbackTests(unittest.TestCase): |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
180 def CheckTraceCallbackUsed(self): |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
181 """ |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
182 Test that the trace callback is invoked once it is set. |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
183 """ |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
184 con = sqlite.connect(":memory:") |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
185 traced_statements = [] |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
186 def trace(statement): |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
187 traced_statements.append(statement) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
188 con.set_trace_callback(trace) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
189 con.execute("create table foo(a, b)") |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
190 self.assertTrue(traced_statements) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
191 self.assertTrue(any("create table foo" in stmt for stmt in traced_statements)) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
192 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
193 def CheckClearTraceCallback(self): |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
194 """ |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
195 Test that setting the trace callback to None clears the previously set callback. |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
196 """ |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
197 con = sqlite.connect(":memory:") |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
198 traced_statements = [] |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
199 def trace(statement): |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
200 traced_statements.append(statement) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
201 con.set_trace_callback(trace) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
202 con.set_trace_callback(None) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
203 con.execute("create table foo(a, b)") |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
204 self.assertFalse(traced_statements, "trace callback was not cleared") |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
205 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
206 def CheckUnicodeContent(self): |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
207 """ |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
208 Test that the statement can contain unicode literals. |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
209 """ |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
210 unicode_value = '\xf6\xe4\xfc\xd6\xc4\xdc\xdf\u20ac' |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
211 con = sqlite.connect(":memory:") |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
212 traced_statements = [] |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
213 def trace(statement): |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
214 traced_statements.append(statement) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
215 con.set_trace_callback(trace) |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
216 con.execute("create table foo(x)") |
|
69124
ce37570768f5
Fix TraceCallbackTests to not use bound parameters (followup to issue #11688)
Antoine Pitrou <solipsis@pitrou.net>
parents:
69121
diff
changeset
|
217 # Can't execute bound parameters as their values don't appear |
|
ce37570768f5
Fix TraceCallbackTests to not use bound parameters (followup to issue #11688)
Antoine Pitrou <solipsis@pitrou.net>
parents:
69121
diff
changeset
|
218 # in traced statements before SQLite 3.6.21 |
|
ce37570768f5
Fix TraceCallbackTests to not use bound parameters (followup to issue #11688)
Antoine Pitrou <solipsis@pitrou.net>
parents:
69121
diff
changeset
|
219 # (cf. http://www.sqlite.org/draft/releaselog/3_6_21.html) |
|
ce37570768f5
Fix TraceCallbackTests to not use bound parameters (followup to issue #11688)
Antoine Pitrou <solipsis@pitrou.net>
parents:
69121
diff
changeset
|
220 con.execute('insert into foo(x) values ("%s")' % unicode_value) |
|
69120
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
221 con.commit() |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
222 self.assertTrue(any(unicode_value in stmt for stmt in traced_statements), |
|
69121
23519bc7d752
Improve error message in test
Antoine Pitrou <solipsis@pitrou.net>
parents:
69120
diff
changeset
|
223 "Unicode data %s garbled in trace callback: %s" |
|
23519bc7d752
Improve error message in test
Antoine Pitrou <solipsis@pitrou.net>
parents:
69120
diff
changeset
|
224 % (ascii(unicode_value), ', '.join(map(ascii, traced_statements)))) |
|
69120
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
225 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
226 |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
227 |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
228 def suite(): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
229 collation_suite = unittest.makeSuite(CollationTests, "Check") |
|
46178
e06e08e8fdce
Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents:
45471
diff
changeset
|
230 progress_suite = unittest.makeSuite(ProgressTests, "Check") |
|
69120
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
231 trace_suite = unittest.makeSuite(TraceCallbackTests, "Check") |
|
575ee55081dc
Issue #11688: Add sqlite3.Connection.set_trace_callback(). Patch by Torsten Landschoff.
Antoine Pitrou <solipsis@pitrou.net>
parents:
55602
diff
changeset
|
232 return unittest.TestSuite((collation_suite, progress_suite, trace_suite)) |
|
37879
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
233 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
234 def test(): |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
235 runner = unittest.TextTestRunner() |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
236 runner.run(suite()) |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
237 |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
238 if __name__ == "__main__": |
|
f731859e9b3b
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
239 test() |
