annotate Lib/sqlite3/test/dbapi.py @ 81343:3a7cd8efc19f

#16852: merge with 3.3.
author Ezio Melotti <ezio.melotti@gmail.com>
date Thu, 10 Jan 2013 03:29:45 +0200
parents d2ab2e4ce3ae
children f13bb1e40fbc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
74726
d2ab2e4ce3ae Make sqlite3 tests editable with Emacs
Petri Lehtinen <petri@digip.org>
parents: 74708
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/dbapi.py: tests for DB-API compliance
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
3 #
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
4 # Copyright (C) 2004-2010 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
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
24 import unittest
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
25 import sqlite3 as sqlite
61073
493bb4585e38 Merged revisions 80552-80556,80564-80566,80568-80571 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59372
diff changeset
26 try:
493bb4585e38 Merged revisions 80552-80556,80564-80566,80568-80571 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59372
diff changeset
27 import threading
493bb4585e38 Merged revisions 80552-80556,80564-80566,80568-80571 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59372
diff changeset
28 except ImportError:
493bb4585e38 Merged revisions 80552-80556,80564-80566,80568-80571 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59372
diff changeset
29 threading = None
37879
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 class ModuleTests(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
32 def CheckAPILevel(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
33 self.assertEqual(sqlite.apilevel, "2.0",
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
34 "apilevel is %s, should be 2.0" % sqlite.apilevel)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
35
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
36 def CheckThreadSafety(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
37 self.assertEqual(sqlite.threadsafety, 1,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
38 "threadsafety is %d, should be 1" % sqlite.threadsafety)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
39
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
40 def CheckParamStyle(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
41 self.assertEqual(sqlite.paramstyle, "qmark",
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
42 "paramstyle is '%s', should be 'qmark'" %
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
43 sqlite.paramstyle)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
44
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
45 def CheckWarning(self):
66340
2beb25369289 Merged revisions 86596 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 59374
diff changeset
46 self.assertTrue(issubclass(sqlite.Warning, Exception),
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41575
diff changeset
47 "Warning is not a subclass of Exception")
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
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
49 def CheckError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
50 self.assertTrue(issubclass(sqlite.Error, Exception),
42084
229c28cb9afb Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 41575
diff changeset
51 "Error is not a subclass of Exception")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
52
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 CheckInterfaceError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
54 self.assertTrue(issubclass(sqlite.InterfaceError, sqlite.Error),
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
55 "InterfaceError is not a subclass of Error")
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 def CheckDatabaseError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
58 self.assertTrue(issubclass(sqlite.DatabaseError, sqlite.Error),
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
59 "DatabaseError is not a subclass of Error")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
60
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
61 def CheckDataError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
62 self.assertTrue(issubclass(sqlite.DataError, sqlite.DatabaseError),
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
63 "DataError is not a subclass of DatabaseError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
64
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
65 def CheckOperationalError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
66 self.assertTrue(issubclass(sqlite.OperationalError, sqlite.DatabaseError),
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
67 "OperationalError is not a subclass of DatabaseError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
68
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
69 def CheckIntegrityError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
70 self.assertTrue(issubclass(sqlite.IntegrityError, sqlite.DatabaseError),
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
71 "IntegrityError is not a subclass of DatabaseError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
72
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
73 def CheckInternalError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
74 self.assertTrue(issubclass(sqlite.InternalError, sqlite.DatabaseError),
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
75 "InternalError is not a subclass of DatabaseError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
76
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
77 def CheckProgrammingError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
78 self.assertTrue(issubclass(sqlite.ProgrammingError, sqlite.DatabaseError),
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
79 "ProgrammingError is not a subclass of DatabaseError")
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 def CheckNotSupportedError(self):
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
82 self.assertTrue(issubclass(sqlite.NotSupportedError,
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
83 sqlite.DatabaseError),
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
84 "NotSupportedError is not a subclass of DatabaseError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
85
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
86 class ConnectionTests(unittest.TestCase):
62009
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
87
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
88 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
89 self.cx = 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
90 cu = self.cx.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
91 cu.execute("create table test(id integer primary key, name text)")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
92 cu.execute("insert into test(name) values (?)", ("foo",))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
93
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
94 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
95 self.cx.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
96
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
97 def CheckCommit(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
98 self.cx.commit()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
99
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
100 def CheckCommitAfterNoChanges(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
101 """
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
102 A commit should also work when no changes were made to the database.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
103 """
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
104 self.cx.commit()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
105 self.cx.commit()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
106
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
107 def CheckRollback(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
108 self.cx.rollback()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
109
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
110 def CheckRollbackAfterNoChanges(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
111 """
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
112 A rollback should also work when no changes were made to the database.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
113 """
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
114 self.cx.rollback()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
115 self.cx.rollback()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
116
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
117 def CheckCursor(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
118 cu = self.cx.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
119
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
120 def CheckFailedOpen(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
121 YOU_CANNOT_OPEN_THIS = "/foo/bar/bla/23534/mydb.db"
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
122 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
123 con = sqlite.connect(YOU_CANNOT_OPEN_THIS)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
124 except sqlite.OperationalError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
125 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
126 self.fail("should have raised an OperationalError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
127
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
128 def CheckClose(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
129 self.cx.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
130
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
131 def CheckExceptions(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
132 # Optional DB-API extension.
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
133 self.assertEqual(self.cx.Warning, sqlite.Warning)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
134 self.assertEqual(self.cx.Error, sqlite.Error)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
135 self.assertEqual(self.cx.InterfaceError, sqlite.InterfaceError)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
136 self.assertEqual(self.cx.DatabaseError, sqlite.DatabaseError)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
137 self.assertEqual(self.cx.DataError, sqlite.DataError)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
138 self.assertEqual(self.cx.OperationalError, sqlite.OperationalError)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
139 self.assertEqual(self.cx.IntegrityError, sqlite.IntegrityError)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
140 self.assertEqual(self.cx.InternalError, sqlite.InternalError)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
141 self.assertEqual(self.cx.ProgrammingError, sqlite.ProgrammingError)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
142 self.assertEqual(self.cx.NotSupportedError, sqlite.NotSupportedError)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
143
62009
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
144 def CheckInTransaction(self):
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
145 # Can't use db from setUp because we want to test initial state.
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
146 cx = sqlite.connect(":memory:")
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
147 cu = cx.cursor()
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
148 self.assertEqual(cx.in_transaction, False)
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
149 cu.execute("create table transactiontest(id integer primary key, name text)")
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
150 self.assertEqual(cx.in_transaction, False)
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
151 cu.execute("insert into transactiontest(name) values (?)", ("foo",))
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
152 self.assertEqual(cx.in_transaction, True)
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
153 cu.execute("select name from transactiontest where name=?", ["foo"])
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
154 row = cu.fetchone()
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
155 self.assertEqual(cx.in_transaction, True)
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
156 cx.commit()
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
157 self.assertEqual(cx.in_transaction, False)
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
158 cu.execute("select name from transactiontest where name=?", ["foo"])
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
159 row = cu.fetchone()
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
160 self.assertEqual(cx.in_transaction, False)
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
161
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
162 def CheckInTransactionRO(self):
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
163 with self.assertRaises(AttributeError):
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
164 self.cx.in_transaction = True
62ca540d8b6e #8845: expose sqlite3 inTransaction as RO in_transaction Connection attribute.
R. David Murray <rdmurray@bitdance.com>
parents: 61073
diff changeset
165
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
166 class CursorTests(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
167 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
168 self.cx = 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
169 self.cu = self.cx.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
170 self.cu.execute("create table test(id integer primary key, name text, income number)")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
171 self.cu.execute("insert into test(name) values (?)", ("foo",))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
172
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
173 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
174 self.cu.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
175 self.cx.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
176
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
177 def CheckExecuteNoArgs(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
178 self.cu.execute("delete from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
179
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
180 def CheckExecuteIllegalSql(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
181 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
182 self.cu.execute("select asdf")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
183 self.fail("should have raised an OperationalError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
184 except sqlite.OperationalError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
185 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
186 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
187 self.fail("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
188
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
189 def CheckExecuteTooMuchSql(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
190 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
191 self.cu.execute("select 5+4; select 4+5")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
192 self.fail("should have raised a Warning")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
193 except sqlite.Warning:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
194 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
195 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
196 self.fail("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
197
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
198 def CheckExecuteTooMuchSql2(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
199 self.cu.execute("select 5+4; -- foo bar")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
200
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
201 def CheckExecuteTooMuchSql3(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
202 self.cu.execute("""
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
203 select 5+4;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
204
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
205 /*
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
206 foo
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
207 */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
208 """)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
209
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
210 def CheckExecuteWrongSqlArg(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
211 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
212 self.cu.execute(42)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
213 self.fail("should have raised a ValueError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
214 except ValueError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
215 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
216 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
217 self.fail("raised wrong exception.")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
218
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
219 def CheckExecuteArgInt(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
220 self.cu.execute("insert into test(id) values (?)", (42,))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
221
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
222 def CheckExecuteArgFloat(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
223 self.cu.execute("insert into test(income) values (?)", (2500.32,))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
224
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
225 def CheckExecuteArgString(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
226 self.cu.execute("insert into test(name) values (?)", ("Hugo",))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
227
74708
2e13011b3719 sqlite3: Handle strings with embedded zeros correctly
Petri Lehtinen <petri@digip.org>
parents: 68257
diff changeset
228 def CheckExecuteArgStringWithZeroByte(self):
2e13011b3719 sqlite3: Handle strings with embedded zeros correctly
Petri Lehtinen <petri@digip.org>
parents: 68257
diff changeset
229 self.cu.execute("insert into test(name) values (?)", ("Hu\x00go",))
2e13011b3719 sqlite3: Handle strings with embedded zeros correctly
Petri Lehtinen <petri@digip.org>
parents: 68257
diff changeset
230
2e13011b3719 sqlite3: Handle strings with embedded zeros correctly
Petri Lehtinen <petri@digip.org>
parents: 68257
diff changeset
231 self.cu.execute("select name from test where id=?", (self.cu.lastrowid,))
2e13011b3719 sqlite3: Handle strings with embedded zeros correctly
Petri Lehtinen <petri@digip.org>
parents: 68257
diff changeset
232 row = self.cu.fetchone()
2e13011b3719 sqlite3: Handle strings with embedded zeros correctly
Petri Lehtinen <petri@digip.org>
parents: 68257
diff changeset
233 self.assertEqual(row[0], "Hu\x00go")
2e13011b3719 sqlite3: Handle strings with embedded zeros correctly
Petri Lehtinen <petri@digip.org>
parents: 68257
diff changeset
234
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
235 def CheckExecuteWrongNoOfArgs1(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
236 # too many parameters
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
237 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
238 self.cu.execute("insert into test(id) values (?)", (17, "Egon"))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
239 self.fail("should have raised ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
240 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
241 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
242
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
243 def CheckExecuteWrongNoOfArgs2(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
244 # too little parameters
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
245 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
246 self.cu.execute("insert into test(id) values (?)")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
247 self.fail("should have raised ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
248 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
249 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
250
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
251 def CheckExecuteWrongNoOfArgs3(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
252 # no parameters, parameters are needed
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
253 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
254 self.cu.execute("insert into test(id) values (?)")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
255 self.fail("should have raised ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
256 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
257 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
258
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: 43487
diff changeset
259 def CheckExecuteParamList(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: 43487
diff changeset
260 self.cu.execute("insert into test(name) values ('foo')")
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
261 self.cu.execute("select name from test where name=?", ["foo"])
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
262 row = self.cu.fetchone()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
263 self.assertEqual(row[0], "foo")
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: 43487
diff changeset
264
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
265 def CheckExecuteParamSequence(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: 43487
diff changeset
266 class L(object):
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
267 def __len__(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: 43487
diff changeset
268 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: 43487
diff changeset
269 def __getitem__(self, x):
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
270 assert x == 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: 43487
diff changeset
271 return "foo"
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
272
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
273 self.cu.execute("insert into test(name) values ('foo')")
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
274 self.cu.execute("select name from test where name=?", L())
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
275 row = self.cu.fetchone()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
276 self.assertEqual(row[0], "foo")
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: 43487
diff changeset
277
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
278 def CheckExecuteDictMapping(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
279 self.cu.execute("insert into test(name) values ('foo')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
280 self.cu.execute("select name from test where name=:name", {"name": "foo"})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
281 row = self.cu.fetchone()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
282 self.assertEqual(row[0], "foo")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
283
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: 43487
diff changeset
284 def CheckExecuteDictMapping_Mapping(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: 43487
diff changeset
285 class D(dict):
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
286 def __missing__(self, key):
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
287 return "foo"
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
288
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
289 self.cu.execute("insert into test(name) values ('foo')")
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
290 self.cu.execute("select name from test where name=:name", D())
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
291 row = self.cu.fetchone()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
292 self.assertEqual(row[0], "foo")
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: 43487
diff changeset
293
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
294 def CheckExecuteDictMappingTooLittleArgs(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
295 self.cu.execute("insert into test(name) values ('foo')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
296 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
297 self.cu.execute("select name from test where name=:name and id=:id", {"name": "foo"})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
298 self.fail("should have raised ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
299 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
300 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
301
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
302 def CheckExecuteDictMappingNoArgs(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
303 self.cu.execute("insert into test(name) values ('foo')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
304 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
305 self.cu.execute("select name from test where name=:name")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
306 self.fail("should have raised ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
307 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
308 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
309
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
310 def CheckExecuteDictMappingUnnamed(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
311 self.cu.execute("insert into test(name) values ('foo')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
312 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
313 self.cu.execute("select name from test where name=?", {"name": "foo"})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
314 self.fail("should have raised ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
315 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
316 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
317
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
318 def CheckClose(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
319 self.cu.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
320
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
321 def CheckRowcountExecute(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
322 self.cu.execute("delete from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
323 self.cu.execute("insert into test(name) values ('foo')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
324 self.cu.execute("insert into test(name) values ('foo')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
325 self.cu.execute("update test set name='bar'")
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
326 self.assertEqual(self.cu.rowcount, 2)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
327
47559
2925b568aacc Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
Georg Brandl <georg@python.org>
parents: 46178
diff changeset
328 def CheckRowcountSelect(self):
2925b568aacc Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
Georg Brandl <georg@python.org>
parents: 46178
diff changeset
329 """
2925b568aacc Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
Georg Brandl <georg@python.org>
parents: 46178
diff changeset
330 pysqlite does not know the rowcount of SELECT statements, because we
2925b568aacc Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
Georg Brandl <georg@python.org>
parents: 46178
diff changeset
331 don't fetch all rows after executing the select statement. The rowcount
2925b568aacc Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
Georg Brandl <georg@python.org>
parents: 46178
diff changeset
332 has thus to be -1.
2925b568aacc Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
Georg Brandl <georg@python.org>
parents: 46178
diff changeset
333 """
2925b568aacc Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
Georg Brandl <georg@python.org>
parents: 46178
diff changeset
334 self.cu.execute("select 5 union select 6")
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
335 self.assertEqual(self.cu.rowcount, -1)
47559
2925b568aacc Merged revisions 63562,63570,63728,63734,63784,63788,63802,63817,63827,63839,63887,63975,63998 via svnmerge from
Georg Brandl <georg@python.org>
parents: 46178
diff changeset
336
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
337 def CheckRowcountExecutemany(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
338 self.cu.execute("delete from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
339 self.cu.executemany("insert into test(name) values (?)", [(1,), (2,), (3,)])
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
340 self.assertEqual(self.cu.rowcount, 3)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
341
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
342 def CheckTotalChanges(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
343 self.cu.execute("insert into test(name) values ('foo')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
344 self.cu.execute("insert into test(name) values ('foo')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
345 if self.cx.total_changes < 2:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
346 self.fail("total changes reported wrong value")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
347
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
348 # Checks for executemany:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
349 # Sequences are required by the DB-API, iterators
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
350 # enhancements in pysqlite.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
351
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
352 def CheckExecuteManySequence(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
353 self.cu.executemany("insert into test(income) values (?)", [(x,) for x in range(100, 110)])
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
354
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
355 def CheckExecuteManyIterator(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
356 class MyIter:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
357 def __init__(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
358 self.value = 5
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
359
41501
0c5019afc55b PEP 3114: rename .next() to .__next__() and add next() builtin.
Georg Brandl <georg@python.org>
parents: 40775
diff changeset
360 def __next__(self):
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
361 if self.value == 10:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
362 raise StopIteration
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
363 else:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
364 self.value += 1
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
365 return (self.value,)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
366
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
367 self.cu.executemany("insert into test(income) values (?)", MyIter())
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
368
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
369 def CheckExecuteManyGenerator(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
370 def mygen():
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
371 for i in range(5):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
372 yield (i,)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
373
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
374 self.cu.executemany("insert into test(income) values (?)", mygen())
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
375
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
376 def CheckExecuteManyWrongSqlArg(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
377 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
378 self.cu.executemany(42, [(3,)])
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
379 self.fail("should have raised a ValueError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
380 except ValueError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
381 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
382 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
383 self.fail("raised wrong exception.")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
384
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
385 def CheckExecuteManySelect(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
386 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
387 self.cu.executemany("select ?", [(3,)])
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
388 self.fail("should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
389 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
390 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
391 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
392 self.fail("raised wrong exception.")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
393
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
394 def CheckExecuteManyNotIterable(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
395 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
396 self.cu.executemany("insert into test(income) values (?)", 42)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
397 self.fail("should have raised a TypeError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
398 except TypeError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
399 return
40587
6b18a095c2e7 SF patch 1631942 by Collin Winter:
Guido van Rossum <guido@python.org>
parents: 37879
diff changeset
400 except Exception as e:
40775
4cdf21a0dbbc Fix most trivially-findable print statements.
Guido van Rossum <guido@python.org>
parents: 40587
diff changeset
401 print("raised", e.__class__)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
402 self.fail("raised wrong exception.")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
403
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
404 def CheckFetchIter(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
405 # Optional DB-API extension.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
406 self.cu.execute("delete from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
407 self.cu.execute("insert into test(id) values (?)", (5,))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
408 self.cu.execute("insert into test(id) values (?)", (6,))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
409 self.cu.execute("select id from test order by id")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
410 lst = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
411 for row in self.cu:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
412 lst.append(row[0])
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
413 self.assertEqual(lst[0], 5)
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
414 self.assertEqual(lst[1], 6)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
415
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
416 def CheckFetchone(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
417 self.cu.execute("select name from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
418 row = self.cu.fetchone()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
419 self.assertEqual(row[0], "foo")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
420 row = self.cu.fetchone()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
421 self.assertEqual(row, None)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
422
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
423 def CheckFetchoneNoStatement(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
424 cur = self.cx.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
425 row = cur.fetchone()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
426 self.assertEqual(row, None)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
427
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
428 def CheckArraySize(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
429 # must default ot 1
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
430 self.assertEqual(self.cu.arraysize, 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
431
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
432 # now set to 2
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
433 self.cu.arraysize = 2
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
434
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
435 # now make the query return 3 rows
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
436 self.cu.execute("delete from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
437 self.cu.execute("insert into test(name) values ('A')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
438 self.cu.execute("insert into test(name) values ('B')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
439 self.cu.execute("insert into test(name) values ('C')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
440 self.cu.execute("select name from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
441 res = self.cu.fetchmany()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
442
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
443 self.assertEqual(len(res), 2)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
444
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
445 def CheckFetchmany(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
446 self.cu.execute("select name from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
447 res = self.cu.fetchmany(100)
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
448 self.assertEqual(len(res), 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
449 res = self.cu.fetchmany(100)
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
450 self.assertEqual(res, [])
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
451
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: 43487
diff changeset
452 def CheckFetchmanyKwArg(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: 43487
diff changeset
453 """Checks if fetchmany works with keyword arguments"""
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
454 self.cu.execute("select name from test")
e06e08e8fdce Bring sqlite3 module up-to-date with what's now in 2.6. Almost. I intentionally
Gerhard Häring <gh@ghaering.de>
parents: 43487
diff changeset
455 res = self.cu.fetchmany(size=100)
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
456 self.assertEqual(len(res), 1)
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: 43487
diff changeset
457
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
458 def CheckFetchall(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
459 self.cu.execute("select name from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
460 res = self.cu.fetchall()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
461 self.assertEqual(len(res), 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
462 res = self.cu.fetchall()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
463 self.assertEqual(res, [])
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
464
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
465 def CheckSetinputsizes(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
466 self.cu.setinputsizes([3, 4, 5])
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
467
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
468 def CheckSetoutputsize(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
469 self.cu.setoutputsize(5, 0)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
470
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
471 def CheckSetoutputsizeNoColumn(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
472 self.cu.setoutputsize(42)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
473
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
474 def CheckCursorConnection(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
475 # Optional DB-API extension.
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
476 self.assertEqual(self.cu.connection, self.cx)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
477
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
478 def CheckWrongCursorCallable(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
479 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
480 def f(): pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
481 cur = self.cx.cursor(f)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
482 self.fail("should have raised a TypeError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
483 except TypeError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
484 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
485 self.fail("should have raised a ValueError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
486
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
487 def CheckCursorWrongClass(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
488 class Foo: pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
489 foo = Foo()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
490 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
491 cur = sqlite.Cursor(foo)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
492 self.fail("should have raised a ValueError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
493 except TypeError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
494 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
495
61073
493bb4585e38 Merged revisions 80552-80556,80564-80566,80568-80571 via svnmerge from
Victor Stinner <victor.stinner@haypocalc.com>
parents: 59372
diff changeset
496 @unittest.skipUnless(threading, 'This test requires threading.')
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
497 class ThreadTests(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
498 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
499 self.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
500 self.cur = self.con.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
501 self.cur.execute("create table test(id integer primary key, name text, bin binary, ratio number, ts timestamp)")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
502
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
503 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
504 self.cur.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
505 self.con.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
506
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
507 def CheckConCursor(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
508 def run(con, errors):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
509 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
510 cur = con.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
511 errors.append("did not raise ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
512 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
513 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
514 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
515 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
516 errors.append("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
517
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
518 errors = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
519 t = threading.Thread(target=run, kwargs={"con": self.con, "errors": errors})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
520 t.start()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
521 t.join()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
522 if len(errors) > 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
523 self.fail("\n".join(errors))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
524
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
525 def CheckConCommit(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
526 def run(con, errors):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
527 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
528 con.commit()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
529 errors.append("did not raise ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
530 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
531 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
532 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
533 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
534 errors.append("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
535
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
536 errors = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
537 t = threading.Thread(target=run, kwargs={"con": self.con, "errors": errors})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
538 t.start()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
539 t.join()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
540 if len(errors) > 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
541 self.fail("\n".join(errors))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
542
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
543 def CheckConRollback(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
544 def run(con, errors):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
545 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
546 con.rollback()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
547 errors.append("did not raise ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
548 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
549 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
550 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
551 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
552 errors.append("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
553
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
554 errors = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
555 t = threading.Thread(target=run, kwargs={"con": self.con, "errors": errors})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
556 t.start()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
557 t.join()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
558 if len(errors) > 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
559 self.fail("\n".join(errors))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
560
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
561 def CheckConClose(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
562 def run(con, errors):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
563 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
564 con.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
565 errors.append("did not raise ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
566 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
567 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
568 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
569 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
570 errors.append("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
571
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
572 errors = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
573 t = threading.Thread(target=run, kwargs={"con": self.con, "errors": errors})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
574 t.start()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
575 t.join()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
576 if len(errors) > 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
577 self.fail("\n".join(errors))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
578
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
579 def CheckCurImplicitBegin(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
580 def run(cur, errors):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
581 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
582 cur.execute("insert into test(name) values ('a')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
583 errors.append("did not raise ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
584 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
585 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
586 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
587 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
588 errors.append("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
589
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
590 errors = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
591 t = threading.Thread(target=run, kwargs={"cur": self.cur, "errors": errors})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
592 t.start()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
593 t.join()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
594 if len(errors) > 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
595 self.fail("\n".join(errors))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
596
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
597 def CheckCurClose(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
598 def run(cur, errors):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
599 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
600 cur.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
601 errors.append("did not raise ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
602 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
603 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
604 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
605 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
606 errors.append("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
607
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
608 errors = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
609 t = threading.Thread(target=run, kwargs={"cur": self.cur, "errors": errors})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
610 t.start()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
611 t.join()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
612 if len(errors) > 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
613 self.fail("\n".join(errors))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
614
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
615 def CheckCurExecute(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
616 def run(cur, errors):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
617 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
618 cur.execute("select name from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
619 errors.append("did not raise ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
620 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
621 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
622 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
623 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
624 errors.append("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
625
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
626 errors = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
627 self.cur.execute("insert into test(name) values ('a')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
628 t = threading.Thread(target=run, kwargs={"cur": self.cur, "errors": errors})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
629 t.start()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
630 t.join()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
631 if len(errors) > 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
632 self.fail("\n".join(errors))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
633
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
634 def CheckCurIterNext(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
635 def run(cur, errors):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
636 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
637 row = cur.fetchone()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
638 errors.append("did not raise ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
639 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
640 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
641 return
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
642 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
643 errors.append("raised wrong exception")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
644
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
645 errors = []
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
646 self.cur.execute("insert into test(name) values ('a')")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
647 self.cur.execute("select name from test")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
648 t = threading.Thread(target=run, kwargs={"cur": self.cur, "errors": errors})
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
649 t.start()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
650 t.join()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
651 if len(errors) > 0:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
652 self.fail("\n".join(errors))
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
653
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
654 class ConstructorTests(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
655 def CheckDate(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
656 d = sqlite.Date(2004, 10, 28)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
657
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
658 def CheckTime(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
659 t = sqlite.Time(12, 39, 35)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
660
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
661 def CheckTimestamp(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
662 ts = sqlite.Timestamp(2004, 10, 28, 12, 39, 35)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
663
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
664 def CheckDateFromTicks(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
665 d = sqlite.DateFromTicks(42)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
666
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
667 def CheckTimeFromTicks(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
668 t = sqlite.TimeFromTicks(42)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
669
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
670 def CheckTimestampFromTicks(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
671 ts = sqlite.TimestampFromTicks(42)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
672
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
673 def CheckBinary(self):
43487
8c10aac37037 Breaking ground for PEP 3137 implementation:
Guido van Rossum <guido@python.org>
parents: 42084
diff changeset
674 b = sqlite.Binary(b"\0'")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
675
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
676 class ExtensionTests(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
677 def CheckScriptStringSql(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
678 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
679 cur = con.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
680 cur.executescript("""
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
681 -- bla bla
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
682 /* a stupid comment */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
683 create table a(i);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
684 insert into a(i) values (5);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
685 """)
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
686 cur.execute("select i from a")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
687 res = cur.fetchone()[0]
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
688 self.assertEqual(res, 5)
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
689
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
690 def CheckScriptSyntaxError(self):
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
691 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
692 cur = con.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
693 raised = False
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
694 try:
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
695 cur.executescript("create table test(x); asdf; create table test2(x)")
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
696 except sqlite.OperationalError:
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
697 raised = True
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
698 self.assertEqual(raised, True, "should have raised an exception")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
699
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
700 def CheckScriptErrorNormal(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
701 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
702 cur = con.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
703 raised = False
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
704 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
705 cur.executescript("create table test(sadfsadfdsa); select foo from hurz;")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
706 except sqlite.OperationalError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
707 raised = True
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
708 self.assertEqual(raised, True, "should have raised an exception")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
709
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
710 def CheckConnectionExecute(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
711 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
712 result = con.execute("select 5").fetchone()[0]
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
713 self.assertEqual(result, 5, "Basic test of Connection.execute")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
714
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
715 def CheckConnectionExecutemany(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
716 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
717 con.execute("create table test(foo)")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
718 con.executemany("insert into test(foo) values (?)", [(3,), (4,)])
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
719 result = con.execute("select foo from test order by foo").fetchall()
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
720 self.assertEqual(result[0][0], 3, "Basic test of Connection.executemany")
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
721 self.assertEqual(result[1][0], 4, "Basic test of Connection.executemany")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
722
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
723 def CheckConnectionExecutescript(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
724 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
725 con.executescript("create table test(foo); insert into test(foo) values (5);")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
726 result = con.execute("select foo from test").fetchone()[0]
55602
680ad8eed33b Merged revisions 73833,73838,73850-73852,73856-73857 via svnmerge from
Georg Brandl <georg@python.org>
parents: 47559
diff changeset
727 self.assertEqual(result, 5, "Basic test of Connection.executescript")
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
728
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
729 class ClosedConTests(unittest.TestCase):
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
730 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
731 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
732
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
733 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
734 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
735
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
736 def CheckClosedConCursor(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
737 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
738 con.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
739 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
740 cur = con.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
741 self.fail("Should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
742 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
743 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
744 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
745 self.fail("Should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
746
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
747 def CheckClosedConCommit(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
748 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
749 con.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
750 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
751 con.commit()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
752 self.fail("Should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
753 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
754 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
755 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
756 self.fail("Should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
757
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
758 def CheckClosedConRollback(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
759 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
760 con.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
761 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
762 con.rollback()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
763 self.fail("Should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
764 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
765 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
766 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
767 self.fail("Should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
768
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
769 def CheckClosedCurExecute(self):
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
770 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
771 cur = con.cursor()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
772 con.close()
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
773 try:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
774 cur.execute("select 4")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
775 self.fail("Should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
776 except sqlite.ProgrammingError:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
777 pass
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
778 except:
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
779 self.fail("Should have raised a ProgrammingError")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
780
59374
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
781 def CheckClosedCreateFunction(self):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
782 con = sqlite.connect(":memory:")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
783 con.close()
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
784 def f(x): return 17
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
785 try:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
786 con.create_function("foo", 1, f)
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
787 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
788 except sqlite.ProgrammingError:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
789 pass
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
790 except:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
791 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
792
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
793 def CheckClosedCreateAggregate(self):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
794 con = sqlite.connect(":memory:")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
795 con.close()
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
796 class Agg:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
797 def __init__(self):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
798 pass
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
799 def step(self, x):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
800 pass
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
801 def finalize(self):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
802 return 17
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
803 try:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
804 con.create_aggregate("foo", 1, Agg)
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
805 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
806 except sqlite.ProgrammingError:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
807 pass
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
808 except:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
809 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
810
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
811 def CheckClosedSetAuthorizer(self):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
812 con = sqlite.connect(":memory:")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
813 con.close()
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
814 def authorizer(*args):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
815 return sqlite.DENY
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
816 try:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
817 con.set_authorizer(authorizer)
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
818 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
819 except sqlite.ProgrammingError:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
820 pass
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
821 except:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
822 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
823
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
824 def CheckClosedSetProgressCallback(self):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
825 con = sqlite.connect(":memory:")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
826 con.close()
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
827 def progress(): pass
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
828 try:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
829 con.set_progress_handler(progress, 100)
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
830 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
831 except sqlite.ProgrammingError:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
832 pass
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
833 except:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
834 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
835
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
836 def CheckClosedCall(self):
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
837 con = sqlite.connect(":memory:")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
838 con.close()
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
839 try:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
840 con()
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
841 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
842 except sqlite.ProgrammingError:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
843 pass
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
844 except:
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
845 self.fail("Should have raised a ProgrammingError")
ecca703bc0df Issue #7670: sqlite3: Fixed crashes when operating on closed connections.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
846
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
847 class ClosedCurTests(unittest.TestCase):
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
848 def setUp(self):
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
849 pass
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
850
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
851 def tearDown(self):
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
852 pass
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
853
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
854 def CheckClosed(self):
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
855 con = sqlite.connect(":memory:")
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
856 cur = con.cursor()
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
857 cur.close()
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
858
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
859 for method_name in ("execute", "executemany", "executescript", "fetchall", "fetchmany", "fetchone"):
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
860 if method_name in ("execute", "executescript"):
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
861 params = ("select 4 union select 5",)
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
862 elif method_name == "executemany":
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
863 params = ("insert into foo(bar) values (?)", [(3,), (4,)])
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
864 else:
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
865 params = []
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
866
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
867 try:
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
868 method = getattr(cur, method_name)
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
869
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
870 method(*params)
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
871 self.fail("Should have raised a ProgrammingError: method " + method_name)
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
872 except sqlite.ProgrammingError:
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
873 pass
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
874 except:
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
875 self.fail("Should have raised a ProgrammingError: " + method_name)
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
876
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
877 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
878 module_suite = unittest.makeSuite(ModuleTests, "Check")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
879 connection_suite = unittest.makeSuite(ConnectionTests, "Check")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
880 cursor_suite = unittest.makeSuite(CursorTests, "Check")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
881 thread_suite = unittest.makeSuite(ThreadTests, "Check")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
882 constructor_suite = unittest.makeSuite(ConstructorTests, "Check")
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
883 ext_suite = unittest.makeSuite(ExtensionTests, "Check")
59372
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
884 closed_con_suite = unittest.makeSuite(ClosedConTests, "Check")
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
885 closed_cur_suite = unittest.makeSuite(ClosedCurTests, "Check")
3003c1656e2a Merged new pysqlite version 2.6.0 from trunk.
Gerhard Häring <gh@ghaering.de>
parents: 55602
diff changeset
886 return unittest.TestSuite((module_suite, connection_suite, cursor_suite, thread_suite, constructor_suite, ext_suite, closed_con_suite, closed_cur_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
887
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
888 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
889 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
890 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
891
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents:
diff changeset
892 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
893 test()