mirror of https://github.com/python/cpython
Merge r73838 from py3k branch. Use the nondeprecated unittest method
names.
This commit is contained in:
parent
cd947e0c6a
commit
1844b0d748
|
@ -45,39 +45,39 @@ class ModuleTests(unittest.TestCase):
|
|||
"Warning is not a subclass of StandardError")
|
||||
|
||||
def CheckError(self):
|
||||
self.failUnless(issubclass(sqlite.Error, StandardError),
|
||||
self.assertTrue(issubclass(sqlite.Error, StandardError),
|
||||
"Error is not a subclass of StandardError")
|
||||
|
||||
def CheckInterfaceError(self):
|
||||
self.failUnless(issubclass(sqlite.InterfaceError, sqlite.Error),
|
||||
self.assertTrue(issubclass(sqlite.InterfaceError, sqlite.Error),
|
||||
"InterfaceError is not a subclass of Error")
|
||||
|
||||
def CheckDatabaseError(self):
|
||||
self.failUnless(issubclass(sqlite.DatabaseError, sqlite.Error),
|
||||
self.assertTrue(issubclass(sqlite.DatabaseError, sqlite.Error),
|
||||
"DatabaseError is not a subclass of Error")
|
||||
|
||||
def CheckDataError(self):
|
||||
self.failUnless(issubclass(sqlite.DataError, sqlite.DatabaseError),
|
||||
self.assertTrue(issubclass(sqlite.DataError, sqlite.DatabaseError),
|
||||
"DataError is not a subclass of DatabaseError")
|
||||
|
||||
def CheckOperationalError(self):
|
||||
self.failUnless(issubclass(sqlite.OperationalError, sqlite.DatabaseError),
|
||||
self.assertTrue(issubclass(sqlite.OperationalError, sqlite.DatabaseError),
|
||||
"OperationalError is not a subclass of DatabaseError")
|
||||
|
||||
def CheckIntegrityError(self):
|
||||
self.failUnless(issubclass(sqlite.IntegrityError, sqlite.DatabaseError),
|
||||
self.assertTrue(issubclass(sqlite.IntegrityError, sqlite.DatabaseError),
|
||||
"IntegrityError is not a subclass of DatabaseError")
|
||||
|
||||
def CheckInternalError(self):
|
||||
self.failUnless(issubclass(sqlite.InternalError, sqlite.DatabaseError),
|
||||
self.assertTrue(issubclass(sqlite.InternalError, sqlite.DatabaseError),
|
||||
"InternalError is not a subclass of DatabaseError")
|
||||
|
||||
def CheckProgrammingError(self):
|
||||
self.failUnless(issubclass(sqlite.ProgrammingError, sqlite.DatabaseError),
|
||||
self.assertTrue(issubclass(sqlite.ProgrammingError, sqlite.DatabaseError),
|
||||
"ProgrammingError is not a subclass of DatabaseError")
|
||||
|
||||
def CheckNotSupportedError(self):
|
||||
self.failUnless(issubclass(sqlite.NotSupportedError,
|
||||
self.assertTrue(issubclass(sqlite.NotSupportedError,
|
||||
sqlite.DatabaseError),
|
||||
"NotSupportedError is not a subclass of DatabaseError")
|
||||
|
||||
|
@ -127,16 +127,16 @@ class ConnectionTests(unittest.TestCase):
|
|||
|
||||
def CheckExceptions(self):
|
||||
# Optional DB-API extension.
|
||||
self.failUnlessEqual(self.cx.Warning, sqlite.Warning)
|
||||
self.failUnlessEqual(self.cx.Error, sqlite.Error)
|
||||
self.failUnlessEqual(self.cx.InterfaceError, sqlite.InterfaceError)
|
||||
self.failUnlessEqual(self.cx.DatabaseError, sqlite.DatabaseError)
|
||||
self.failUnlessEqual(self.cx.DataError, sqlite.DataError)
|
||||
self.failUnlessEqual(self.cx.OperationalError, sqlite.OperationalError)
|
||||
self.failUnlessEqual(self.cx.IntegrityError, sqlite.IntegrityError)
|
||||
self.failUnlessEqual(self.cx.InternalError, sqlite.InternalError)
|
||||
self.failUnlessEqual(self.cx.ProgrammingError, sqlite.ProgrammingError)
|
||||
self.failUnlessEqual(self.cx.NotSupportedError, sqlite.NotSupportedError)
|
||||
self.assertEqual(self.cx.Warning, sqlite.Warning)
|
||||
self.assertEqual(self.cx.Error, sqlite.Error)
|
||||
self.assertEqual(self.cx.InterfaceError, sqlite.InterfaceError)
|
||||
self.assertEqual(self.cx.DatabaseError, sqlite.DatabaseError)
|
||||
self.assertEqual(self.cx.DataError, sqlite.DataError)
|
||||
self.assertEqual(self.cx.OperationalError, sqlite.OperationalError)
|
||||
self.assertEqual(self.cx.IntegrityError, sqlite.IntegrityError)
|
||||
self.assertEqual(self.cx.InternalError, sqlite.InternalError)
|
||||
self.assertEqual(self.cx.ProgrammingError, sqlite.ProgrammingError)
|
||||
self.assertEqual(self.cx.NotSupportedError, sqlite.NotSupportedError)
|
||||
|
||||
class CursorTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -228,7 +228,7 @@ class CursorTests(unittest.TestCase):
|
|||
self.cu.execute("insert into test(name) values ('foo')")
|
||||
self.cu.execute("select name from test where name=?", ["foo"])
|
||||
row = self.cu.fetchone()
|
||||
self.failUnlessEqual(row[0], "foo")
|
||||
self.assertEqual(row[0], "foo")
|
||||
|
||||
def CheckExecuteParamSequence(self):
|
||||
class L(object):
|
||||
|
@ -241,13 +241,13 @@ class CursorTests(unittest.TestCase):
|
|||
self.cu.execute("insert into test(name) values ('foo')")
|
||||
self.cu.execute("select name from test where name=?", L())
|
||||
row = self.cu.fetchone()
|
||||
self.failUnlessEqual(row[0], "foo")
|
||||
self.assertEqual(row[0], "foo")
|
||||
|
||||
def CheckExecuteDictMapping(self):
|
||||
self.cu.execute("insert into test(name) values ('foo')")
|
||||
self.cu.execute("select name from test where name=:name", {"name": "foo"})
|
||||
row = self.cu.fetchone()
|
||||
self.failUnlessEqual(row[0], "foo")
|
||||
self.assertEqual(row[0], "foo")
|
||||
|
||||
def CheckExecuteDictMapping_Mapping(self):
|
||||
# Test only works with Python 2.5 or later
|
||||
|
@ -261,7 +261,7 @@ class CursorTests(unittest.TestCase):
|
|||
self.cu.execute("insert into test(name) values ('foo')")
|
||||
self.cu.execute("select name from test where name=:name", D())
|
||||
row = self.cu.fetchone()
|
||||
self.failUnlessEqual(row[0], "foo")
|
||||
self.assertEqual(row[0], "foo")
|
||||
|
||||
def CheckExecuteDictMappingTooLittleArgs(self):
|
||||
self.cu.execute("insert into test(name) values ('foo')")
|
||||
|
@ -295,7 +295,7 @@ class CursorTests(unittest.TestCase):
|
|||
self.cu.execute("insert into test(name) values ('foo')")
|
||||
self.cu.execute("insert into test(name) values ('foo')")
|
||||
self.cu.execute("update test set name='bar'")
|
||||
self.failUnlessEqual(self.cu.rowcount, 2)
|
||||
self.assertEqual(self.cu.rowcount, 2)
|
||||
|
||||
def CheckRowcountSelect(self):
|
||||
"""
|
||||
|
@ -304,12 +304,12 @@ class CursorTests(unittest.TestCase):
|
|||
has thus to be -1.
|
||||
"""
|
||||
self.cu.execute("select 5 union select 6")
|
||||
self.failUnlessEqual(self.cu.rowcount, -1)
|
||||
self.assertEqual(self.cu.rowcount, -1)
|
||||
|
||||
def CheckRowcountExecutemany(self):
|
||||
self.cu.execute("delete from test")
|
||||
self.cu.executemany("insert into test(name) values (?)", [(1,), (2,), (3,)])
|
||||
self.failUnlessEqual(self.cu.rowcount, 3)
|
||||
self.assertEqual(self.cu.rowcount, 3)
|
||||
|
||||
def CheckTotalChanges(self):
|
||||
self.cu.execute("insert into test(name) values ('foo')")
|
||||
|
@ -382,24 +382,24 @@ class CursorTests(unittest.TestCase):
|
|||
lst = []
|
||||
for row in self.cu:
|
||||
lst.append(row[0])
|
||||
self.failUnlessEqual(lst[0], 5)
|
||||
self.failUnlessEqual(lst[1], 6)
|
||||
self.assertEqual(lst[0], 5)
|
||||
self.assertEqual(lst[1], 6)
|
||||
|
||||
def CheckFetchone(self):
|
||||
self.cu.execute("select name from test")
|
||||
row = self.cu.fetchone()
|
||||
self.failUnlessEqual(row[0], "foo")
|
||||
self.assertEqual(row[0], "foo")
|
||||
row = self.cu.fetchone()
|
||||
self.failUnlessEqual(row, None)
|
||||
self.assertEqual(row, None)
|
||||
|
||||
def CheckFetchoneNoStatement(self):
|
||||
cur = self.cx.cursor()
|
||||
row = cur.fetchone()
|
||||
self.failUnlessEqual(row, None)
|
||||
self.assertEqual(row, None)
|
||||
|
||||
def CheckArraySize(self):
|
||||
# must default ot 1
|
||||
self.failUnlessEqual(self.cu.arraysize, 1)
|
||||
self.assertEqual(self.cu.arraysize, 1)
|
||||
|
||||
# now set to 2
|
||||
self.cu.arraysize = 2
|
||||
|
@ -412,27 +412,27 @@ class CursorTests(unittest.TestCase):
|
|||
self.cu.execute("select name from test")
|
||||
res = self.cu.fetchmany()
|
||||
|
||||
self.failUnlessEqual(len(res), 2)
|
||||
self.assertEqual(len(res), 2)
|
||||
|
||||
def CheckFetchmany(self):
|
||||
self.cu.execute("select name from test")
|
||||
res = self.cu.fetchmany(100)
|
||||
self.failUnlessEqual(len(res), 1)
|
||||
self.assertEqual(len(res), 1)
|
||||
res = self.cu.fetchmany(100)
|
||||
self.failUnlessEqual(res, [])
|
||||
self.assertEqual(res, [])
|
||||
|
||||
def CheckFetchmanyKwArg(self):
|
||||
"""Checks if fetchmany works with keyword arguments"""
|
||||
self.cu.execute("select name from test")
|
||||
res = self.cu.fetchmany(size=100)
|
||||
self.failUnlessEqual(len(res), 1)
|
||||
self.assertEqual(len(res), 1)
|
||||
|
||||
def CheckFetchall(self):
|
||||
self.cu.execute("select name from test")
|
||||
res = self.cu.fetchall()
|
||||
self.failUnlessEqual(len(res), 1)
|
||||
self.assertEqual(len(res), 1)
|
||||
res = self.cu.fetchall()
|
||||
self.failUnlessEqual(res, [])
|
||||
self.assertEqual(res, [])
|
||||
|
||||
def CheckSetinputsizes(self):
|
||||
self.cu.setinputsizes([3, 4, 5])
|
||||
|
@ -445,7 +445,7 @@ class CursorTests(unittest.TestCase):
|
|||
|
||||
def CheckCursorConnection(self):
|
||||
# Optional DB-API extension.
|
||||
self.failUnlessEqual(self.cu.connection, self.cx)
|
||||
self.assertEqual(self.cu.connection, self.cx)
|
||||
|
||||
def CheckWrongCursorCallable(self):
|
||||
try:
|
||||
|
@ -656,7 +656,7 @@ class ExtensionTests(unittest.TestCase):
|
|||
""")
|
||||
cur.execute("select i from a")
|
||||
res = cur.fetchone()[0]
|
||||
self.failUnlessEqual(res, 5)
|
||||
self.assertEqual(res, 5)
|
||||
|
||||
def CheckScriptStringUnicode(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
|
@ -670,7 +670,7 @@ class ExtensionTests(unittest.TestCase):
|
|||
""")
|
||||
cur.execute("select i from a")
|
||||
res = cur.fetchone()[0]
|
||||
self.failUnlessEqual(res, 6)
|
||||
self.assertEqual(res, 6)
|
||||
|
||||
def CheckScriptErrorIncomplete(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
|
@ -680,7 +680,7 @@ class ExtensionTests(unittest.TestCase):
|
|||
cur.executescript("create table test(sadfsadfdsa")
|
||||
except sqlite.ProgrammingError:
|
||||
raised = True
|
||||
self.failUnlessEqual(raised, True, "should have raised an exception")
|
||||
self.assertEqual(raised, True, "should have raised an exception")
|
||||
|
||||
def CheckScriptErrorNormal(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
|
@ -690,26 +690,26 @@ class ExtensionTests(unittest.TestCase):
|
|||
cur.executescript("create table test(sadfsadfdsa); select foo from hurz;")
|
||||
except sqlite.OperationalError:
|
||||
raised = True
|
||||
self.failUnlessEqual(raised, True, "should have raised an exception")
|
||||
self.assertEqual(raised, True, "should have raised an exception")
|
||||
|
||||
def CheckConnectionExecute(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
result = con.execute("select 5").fetchone()[0]
|
||||
self.failUnlessEqual(result, 5, "Basic test of Connection.execute")
|
||||
self.assertEqual(result, 5, "Basic test of Connection.execute")
|
||||
|
||||
def CheckConnectionExecutemany(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
con.execute("create table test(foo)")
|
||||
con.executemany("insert into test(foo) values (?)", [(3,), (4,)])
|
||||
result = con.execute("select foo from test order by foo").fetchall()
|
||||
self.failUnlessEqual(result[0][0], 3, "Basic test of Connection.executemany")
|
||||
self.failUnlessEqual(result[1][0], 4, "Basic test of Connection.executemany")
|
||||
self.assertEqual(result[0][0], 3, "Basic test of Connection.executemany")
|
||||
self.assertEqual(result[1][0], 4, "Basic test of Connection.executemany")
|
||||
|
||||
def CheckConnectionExecutescript(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
con.executescript("create table test(foo); insert into test(foo) values (5);")
|
||||
result = con.execute("select foo from test").fetchone()[0]
|
||||
self.failUnlessEqual(result, 5, "Basic test of Connection.executescript")
|
||||
self.assertEqual(result, 5, "Basic test of Connection.executescript")
|
||||
|
||||
class ClosedTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -47,7 +47,7 @@ class ConnectionFactoryTests(unittest.TestCase):
|
|||
self.con.close()
|
||||
|
||||
def CheckIsInstance(self):
|
||||
self.failUnless(isinstance(self.con,
|
||||
self.assertTrue(isinstance(self.con,
|
||||
MyConnection),
|
||||
"connection is not instance of MyConnection")
|
||||
|
||||
|
@ -60,7 +60,7 @@ class CursorFactoryTests(unittest.TestCase):
|
|||
|
||||
def CheckIsInstance(self):
|
||||
cur = self.con.cursor(factory=MyCursor)
|
||||
self.failUnless(isinstance(cur,
|
||||
self.assertTrue(isinstance(cur,
|
||||
MyCursor),
|
||||
"cursor is not instance of MyCursor")
|
||||
|
||||
|
@ -72,7 +72,7 @@ class RowFactoryTestsBackwardsCompat(unittest.TestCase):
|
|||
cur = self.con.cursor(factory=MyCursor)
|
||||
cur.execute("select 4+5 as foo")
|
||||
row = cur.fetchone()
|
||||
self.failUnless(isinstance(row,
|
||||
self.assertTrue(isinstance(row,
|
||||
dict),
|
||||
"row is not instance of dict")
|
||||
cur.close()
|
||||
|
@ -87,28 +87,28 @@ class RowFactoryTests(unittest.TestCase):
|
|||
def CheckCustomFactory(self):
|
||||
self.con.row_factory = lambda cur, row: list(row)
|
||||
row = self.con.execute("select 1, 2").fetchone()
|
||||
self.failUnless(isinstance(row,
|
||||
self.assertTrue(isinstance(row,
|
||||
list),
|
||||
"row is not instance of list")
|
||||
|
||||
def CheckSqliteRowIndex(self):
|
||||
self.con.row_factory = sqlite.Row
|
||||
row = self.con.execute("select 1 as a, 2 as b").fetchone()
|
||||
self.failUnless(isinstance(row,
|
||||
self.assertTrue(isinstance(row,
|
||||
sqlite.Row),
|
||||
"row is not instance of sqlite.Row")
|
||||
|
||||
col1, col2 = row["a"], row["b"]
|
||||
self.failUnless(col1 == 1, "by name: wrong result for column 'a'")
|
||||
self.failUnless(col2 == 2, "by name: wrong result for column 'a'")
|
||||
self.assertTrue(col1 == 1, "by name: wrong result for column 'a'")
|
||||
self.assertTrue(col2 == 2, "by name: wrong result for column 'a'")
|
||||
|
||||
col1, col2 = row["A"], row["B"]
|
||||
self.failUnless(col1 == 1, "by name: wrong result for column 'A'")
|
||||
self.failUnless(col2 == 2, "by name: wrong result for column 'B'")
|
||||
self.assertTrue(col1 == 1, "by name: wrong result for column 'A'")
|
||||
self.assertTrue(col2 == 2, "by name: wrong result for column 'B'")
|
||||
|
||||
col1, col2 = row[0], row[1]
|
||||
self.failUnless(col1 == 1, "by index: wrong result for column 0")
|
||||
self.failUnless(col2 == 2, "by index: wrong result for column 1")
|
||||
self.assertTrue(col1 == 1, "by index: wrong result for column 0")
|
||||
self.assertTrue(col2 == 2, "by index: wrong result for column 1")
|
||||
|
||||
def CheckSqliteRowIter(self):
|
||||
"""Checks if the row object is iterable"""
|
||||
|
@ -128,8 +128,8 @@ class RowFactoryTests(unittest.TestCase):
|
|||
self.con.row_factory = sqlite.Row
|
||||
row = self.con.execute("select 1 as a, 2 as b").fetchone()
|
||||
d = dict(row)
|
||||
self.failUnlessEqual(d["a"], row["a"])
|
||||
self.failUnlessEqual(d["b"], row["b"])
|
||||
self.assertEqual(d["a"], row["a"])
|
||||
self.assertEqual(d["b"], row["b"])
|
||||
|
||||
def CheckSqliteRowHashCmp(self):
|
||||
"""Checks if the row object compares and hashes correctly"""
|
||||
|
@ -138,18 +138,18 @@ class RowFactoryTests(unittest.TestCase):
|
|||
row_2 = self.con.execute("select 1 as a, 2 as b").fetchone()
|
||||
row_3 = self.con.execute("select 1 as a, 3 as b").fetchone()
|
||||
|
||||
self.failUnless(row_1 == row_1)
|
||||
self.failUnless(row_1 == row_2)
|
||||
self.failUnless(row_2 != row_3)
|
||||
self.assertTrue(row_1 == row_1)
|
||||
self.assertTrue(row_1 == row_2)
|
||||
self.assertTrue(row_2 != row_3)
|
||||
|
||||
self.failIf(row_1 != row_1)
|
||||
self.failIf(row_1 != row_2)
|
||||
self.failIf(row_2 == row_3)
|
||||
self.assertFalse(row_1 != row_1)
|
||||
self.assertFalse(row_1 != row_2)
|
||||
self.assertFalse(row_2 == row_3)
|
||||
|
||||
self.failUnlessEqual(row_1, row_2)
|
||||
self.failUnlessEqual(hash(row_1), hash(row_2))
|
||||
self.failIfEqual(row_1, row_3)
|
||||
self.failIfEqual(hash(row_1), hash(row_3))
|
||||
self.assertEqual(row_1, row_2)
|
||||
self.assertEqual(hash(row_1), hash(row_2))
|
||||
self.assertNotEqual(row_1, row_3)
|
||||
self.assertNotEqual(hash(row_1), hash(row_3))
|
||||
|
||||
def tearDown(self):
|
||||
self.con.close()
|
||||
|
@ -161,21 +161,21 @@ class TextFactoryTests(unittest.TestCase):
|
|||
def CheckUnicode(self):
|
||||
austria = unicode("Österreich", "latin1")
|
||||
row = self.con.execute("select ?", (austria,)).fetchone()
|
||||
self.failUnless(type(row[0]) == unicode, "type of row[0] must be unicode")
|
||||
self.assertTrue(type(row[0]) == unicode, "type of row[0] must be unicode")
|
||||
|
||||
def CheckString(self):
|
||||
self.con.text_factory = str
|
||||
austria = unicode("Österreich", "latin1")
|
||||
row = self.con.execute("select ?", (austria,)).fetchone()
|
||||
self.failUnless(type(row[0]) == str, "type of row[0] must be str")
|
||||
self.failUnless(row[0] == austria.encode("utf-8"), "column must equal original data in UTF-8")
|
||||
self.assertTrue(type(row[0]) == str, "type of row[0] must be str")
|
||||
self.assertTrue(row[0] == austria.encode("utf-8"), "column must equal original data in UTF-8")
|
||||
|
||||
def CheckCustom(self):
|
||||
self.con.text_factory = lambda x: unicode(x, "utf-8", "ignore")
|
||||
austria = unicode("Österreich", "latin1")
|
||||
row = self.con.execute("select ?", (austria.encode("latin1"),)).fetchone()
|
||||
self.failUnless(type(row[0]) == unicode, "type of row[0] must be unicode")
|
||||
self.failUnless(row[0].endswith(u"reich"), "column must contain original data")
|
||||
self.assertTrue(type(row[0]) == unicode, "type of row[0] must be unicode")
|
||||
self.assertTrue(row[0].endswith(u"reich"), "column must contain original data")
|
||||
|
||||
def CheckOptimizedUnicode(self):
|
||||
self.con.text_factory = sqlite.OptimizedUnicode
|
||||
|
@ -183,8 +183,8 @@ class TextFactoryTests(unittest.TestCase):
|
|||
germany = unicode("Deutchland")
|
||||
a_row = self.con.execute("select ?", (austria,)).fetchone()
|
||||
d_row = self.con.execute("select ?", (germany,)).fetchone()
|
||||
self.failUnless(type(a_row[0]) == unicode, "type of non-ASCII row must be unicode")
|
||||
self.failUnless(type(d_row[0]) == str, "type of ASCII-only row must be str")
|
||||
self.assertTrue(type(a_row[0]) == unicode, "type of non-ASCII row must be unicode")
|
||||
self.assertTrue(type(d_row[0]) == str, "type of ASCII-only row must be str")
|
||||
|
||||
def tearDown(self):
|
||||
self.con.close()
|
||||
|
|
|
@ -37,7 +37,7 @@ class CollationTests(unittest.TestCase):
|
|||
con.create_collation("X", 42)
|
||||
self.fail("should have raised a TypeError")
|
||||
except TypeError, e:
|
||||
self.failUnlessEqual(e.args[0], "parameter must be callable")
|
||||
self.assertEqual(e.args[0], "parameter must be callable")
|
||||
|
||||
def CheckCreateCollationNotAscii(self):
|
||||
con = sqlite.connect(":memory:")
|
||||
|
@ -74,7 +74,7 @@ class CollationTests(unittest.TestCase):
|
|||
result = con.execute(sql).fetchall()
|
||||
self.fail("should have raised an OperationalError")
|
||||
except sqlite.OperationalError, e:
|
||||
self.failUnlessEqual(e.args[0].lower(), "no such collation sequence: mycoll")
|
||||
self.assertEqual(e.args[0].lower(), "no such collation sequence: mycoll")
|
||||
|
||||
def CheckCollationRegisterTwice(self):
|
||||
"""
|
||||
|
@ -119,7 +119,7 @@ class ProgressTests(unittest.TestCase):
|
|||
con.execute("""
|
||||
create table foo(a, b)
|
||||
""")
|
||||
self.failUnless(progress_calls)
|
||||
self.assertTrue(progress_calls)
|
||||
|
||||
|
||||
def CheckOpcodeCount(self):
|
||||
|
@ -143,7 +143,7 @@ class ProgressTests(unittest.TestCase):
|
|||
create table bar (a, b)
|
||||
""")
|
||||
second_count = len(progress_calls)
|
||||
self.failUnless(first_count > second_count)
|
||||
self.assertTrue(first_count > second_count)
|
||||
|
||||
def CheckCancelOperation(self):
|
||||
"""
|
||||
|
@ -173,7 +173,7 @@ class ProgressTests(unittest.TestCase):
|
|||
con.set_progress_handler(progress, 1)
|
||||
con.set_progress_handler(None, 1)
|
||||
con.execute("select 1 union select 2 union select 3").fetchall()
|
||||
self.failUnlessEqual(action, 0, "progress handler was not cleared")
|
||||
self.assertEqual(action, 0, "progress handler was not cleared")
|
||||
|
||||
def suite():
|
||||
collation_suite = unittest.makeSuite(CollationTests, "Check")
|
||||
|
|
|
@ -54,19 +54,19 @@ class ContextTests(unittest.TestCase):
|
|||
self.con.execute("insert into test(c) values ('foo')")
|
||||
self.con.rollback()
|
||||
count = self.con.execute("select count(*) from test").fetchone()[0]
|
||||
self.failUnlessEqual(count, 1)
|
||||
self.assertEqual(count, 1)
|
||||
|
||||
def CheckContextManagerRollback(self):
|
||||
"""Is a rollback called in the context manager?"""
|
||||
global did_rollback
|
||||
self.failUnlessEqual(did_rollback, False)
|
||||
self.assertEqual(did_rollback, False)
|
||||
try:
|
||||
with self.con:
|
||||
self.con.execute("insert into test(c) values (4)")
|
||||
self.con.execute("insert into test(c) values (4)")
|
||||
except sqlite.IntegrityError:
|
||||
pass
|
||||
self.failUnlessEqual(did_rollback, True)
|
||||
self.assertEqual(did_rollback, True)
|
||||
|
||||
def suite():
|
||||
ctx_suite = unittest.makeSuite(ContextTests, "Check")
|
||||
|
|
|
@ -65,10 +65,10 @@ class RegressionTests(unittest.TestCase):
|
|||
def CheckColumnNameWithSpaces(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute('select 1 as "foo bar [datetime]"')
|
||||
self.failUnlessEqual(cur.description[0][0], "foo bar")
|
||||
self.assertEqual(cur.description[0][0], "foo bar")
|
||||
|
||||
cur.execute('select 1 as "foo baz"')
|
||||
self.failUnlessEqual(cur.description[0][0], "foo baz")
|
||||
self.assertEqual(cur.description[0][0], "foo baz")
|
||||
|
||||
def CheckStatementAvailable(self):
|
||||
# pysqlite up to 2.3.2 crashed on this, because the active statement handle was not checked
|
||||
|
|
|
@ -59,14 +59,14 @@ class TransactionTests(unittest.TestCase):
|
|||
self.cur1.execute("create table test2(j)")
|
||||
self.cur2.execute("select i from test")
|
||||
res = self.cur2.fetchall()
|
||||
self.failUnlessEqual(len(res), 1)
|
||||
self.assertEqual(len(res), 1)
|
||||
|
||||
def CheckInsertStartsTransaction(self):
|
||||
self.cur1.execute("create table test(i)")
|
||||
self.cur1.execute("insert into test(i) values (5)")
|
||||
self.cur2.execute("select i from test")
|
||||
res = self.cur2.fetchall()
|
||||
self.failUnlessEqual(len(res), 0)
|
||||
self.assertEqual(len(res), 0)
|
||||
|
||||
def CheckUpdateStartsTransaction(self):
|
||||
self.cur1.execute("create table test(i)")
|
||||
|
@ -75,7 +75,7 @@ class TransactionTests(unittest.TestCase):
|
|||
self.cur1.execute("update test set i=6")
|
||||
self.cur2.execute("select i from test")
|
||||
res = self.cur2.fetchone()[0]
|
||||
self.failUnlessEqual(res, 5)
|
||||
self.assertEqual(res, 5)
|
||||
|
||||
def CheckDeleteStartsTransaction(self):
|
||||
self.cur1.execute("create table test(i)")
|
||||
|
@ -84,7 +84,7 @@ class TransactionTests(unittest.TestCase):
|
|||
self.cur1.execute("delete from test")
|
||||
self.cur2.execute("select i from test")
|
||||
res = self.cur2.fetchall()
|
||||
self.failUnlessEqual(len(res), 1)
|
||||
self.assertEqual(len(res), 1)
|
||||
|
||||
def CheckReplaceStartsTransaction(self):
|
||||
self.cur1.execute("create table test(i)")
|
||||
|
@ -93,24 +93,24 @@ class TransactionTests(unittest.TestCase):
|
|||
self.cur1.execute("replace into test(i) values (6)")
|
||||
self.cur2.execute("select i from test")
|
||||
res = self.cur2.fetchall()
|
||||
self.failUnlessEqual(len(res), 1)
|
||||
self.failUnlessEqual(res[0][0], 5)
|
||||
self.assertEqual(len(res), 1)
|
||||
self.assertEqual(res[0][0], 5)
|
||||
|
||||
def CheckToggleAutoCommit(self):
|
||||
self.cur1.execute("create table test(i)")
|
||||
self.cur1.execute("insert into test(i) values (5)")
|
||||
self.con1.isolation_level = None
|
||||
self.failUnlessEqual(self.con1.isolation_level, None)
|
||||
self.assertEqual(self.con1.isolation_level, None)
|
||||
self.cur2.execute("select i from test")
|
||||
res = self.cur2.fetchall()
|
||||
self.failUnlessEqual(len(res), 1)
|
||||
self.assertEqual(len(res), 1)
|
||||
|
||||
self.con1.isolation_level = "DEFERRED"
|
||||
self.failUnlessEqual(self.con1.isolation_level , "DEFERRED")
|
||||
self.assertEqual(self.con1.isolation_level , "DEFERRED")
|
||||
self.cur1.execute("insert into test(i) values (5)")
|
||||
self.cur2.execute("select i from test")
|
||||
res = self.cur2.fetchall()
|
||||
self.failUnlessEqual(len(res), 1)
|
||||
self.assertEqual(len(res), 1)
|
||||
|
||||
def CheckRaiseTimeout(self):
|
||||
if sqlite.sqlite_version_info < (3, 2, 2):
|
||||
|
|
|
@ -39,39 +39,39 @@ class SqliteTypeTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(s) values (?)", (u"Österreich",))
|
||||
self.cur.execute("select s from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], u"Österreich")
|
||||
self.assertEqual(row[0], u"Österreich")
|
||||
|
||||
def CheckSmallInt(self):
|
||||
self.cur.execute("insert into test(i) values (?)", (42,))
|
||||
self.cur.execute("select i from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], 42)
|
||||
self.assertEqual(row[0], 42)
|
||||
|
||||
def CheckLargeInt(self):
|
||||
num = 2**40
|
||||
self.cur.execute("insert into test(i) values (?)", (num,))
|
||||
self.cur.execute("select i from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], num)
|
||||
self.assertEqual(row[0], num)
|
||||
|
||||
def CheckFloat(self):
|
||||
val = 3.14
|
||||
self.cur.execute("insert into test(f) values (?)", (val,))
|
||||
self.cur.execute("select f from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], val)
|
||||
self.assertEqual(row[0], val)
|
||||
|
||||
def CheckBlob(self):
|
||||
val = buffer("Guglhupf")
|
||||
self.cur.execute("insert into test(b) values (?)", (val,))
|
||||
self.cur.execute("select b from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], val)
|
||||
self.assertEqual(row[0], val)
|
||||
|
||||
def CheckUnicodeExecute(self):
|
||||
self.cur.execute(u"select 'Österreich'")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], u"Österreich")
|
||||
self.assertEqual(row[0], u"Österreich")
|
||||
|
||||
class DeclTypesTests(unittest.TestCase):
|
||||
class Foo:
|
||||
|
@ -122,14 +122,14 @@ class DeclTypesTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(s) values (?)", ("foo",))
|
||||
self.cur.execute('select s as "s [WRONG]" from test')
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], "foo")
|
||||
self.assertEqual(row[0], "foo")
|
||||
|
||||
def CheckSmallInt(self):
|
||||
# default
|
||||
self.cur.execute("insert into test(i) values (?)", (42,))
|
||||
self.cur.execute("select i from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], 42)
|
||||
self.assertEqual(row[0], 42)
|
||||
|
||||
def CheckLargeInt(self):
|
||||
# default
|
||||
|
@ -137,7 +137,7 @@ class DeclTypesTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(i) values (?)", (num,))
|
||||
self.cur.execute("select i from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], num)
|
||||
self.assertEqual(row[0], num)
|
||||
|
||||
def CheckFloat(self):
|
||||
# custom
|
||||
|
@ -145,20 +145,20 @@ class DeclTypesTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(f) values (?)", (val,))
|
||||
self.cur.execute("select f from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], 47.2)
|
||||
self.assertEqual(row[0], 47.2)
|
||||
|
||||
def CheckBool(self):
|
||||
# custom
|
||||
self.cur.execute("insert into test(b) values (?)", (False,))
|
||||
self.cur.execute("select b from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], False)
|
||||
self.assertEqual(row[0], False)
|
||||
|
||||
self.cur.execute("delete from test")
|
||||
self.cur.execute("insert into test(b) values (?)", (True,))
|
||||
self.cur.execute("select b from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], True)
|
||||
self.assertEqual(row[0], True)
|
||||
|
||||
def CheckUnicode(self):
|
||||
# default
|
||||
|
@ -166,14 +166,14 @@ class DeclTypesTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(u) values (?)", (val,))
|
||||
self.cur.execute("select u from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], val)
|
||||
self.assertEqual(row[0], val)
|
||||
|
||||
def CheckFoo(self):
|
||||
val = DeclTypesTests.Foo("bla")
|
||||
self.cur.execute("insert into test(foo) values (?)", (val,))
|
||||
self.cur.execute("select foo from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], val)
|
||||
self.assertEqual(row[0], val)
|
||||
|
||||
def CheckUnsupportedSeq(self):
|
||||
class Bar: pass
|
||||
|
@ -203,20 +203,20 @@ class DeclTypesTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(bin) values (?)", (val,))
|
||||
self.cur.execute("select bin from test")
|
||||
row = self.cur.fetchone()
|
||||
self.failUnlessEqual(row[0], val)
|
||||
self.assertEqual(row[0], val)
|
||||
|
||||
def CheckNumber1(self):
|
||||
self.cur.execute("insert into test(n1) values (5)")
|
||||
value = self.cur.execute("select n1 from test").fetchone()[0]
|
||||
# if the converter is not used, it's an int instead of a float
|
||||
self.failUnlessEqual(type(value), float)
|
||||
self.assertEqual(type(value), float)
|
||||
|
||||
def CheckNumber2(self):
|
||||
"""Checks wether converter names are cut off at '(' characters"""
|
||||
self.cur.execute("insert into test(n2) values (5)")
|
||||
value = self.cur.execute("select n2 from test").fetchone()[0]
|
||||
# if the converter is not used, it's an int instead of a float
|
||||
self.failUnlessEqual(type(value), float)
|
||||
self.assertEqual(type(value), float)
|
||||
|
||||
class ColNamesTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -245,28 +245,28 @@ class ColNamesTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(x) values (?)", ("xxx",))
|
||||
self.cur.execute("select x from test")
|
||||
val = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, "xxx")
|
||||
self.assertEqual(val, "xxx")
|
||||
|
||||
def CheckNone(self):
|
||||
self.cur.execute("insert into test(x) values (?)", (None,))
|
||||
self.cur.execute("select x from test")
|
||||
val = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, None)
|
||||
self.assertEqual(val, None)
|
||||
|
||||
def CheckColName(self):
|
||||
self.cur.execute("insert into test(x) values (?)", ("xxx",))
|
||||
self.cur.execute('select x as "x [bar]" from test')
|
||||
val = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, "<xxx>")
|
||||
self.assertEqual(val, "<xxx>")
|
||||
|
||||
# Check if the stripping of colnames works. Everything after the first
|
||||
# whitespace should be stripped.
|
||||
self.failUnlessEqual(self.cur.description[0][0], "x")
|
||||
self.assertEqual(self.cur.description[0][0], "x")
|
||||
|
||||
def CheckCaseInConverterName(self):
|
||||
self.cur.execute("""select 'other' as "x [b1b1]\"""")
|
||||
val = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, "MARKER")
|
||||
self.assertEqual(val, "MARKER")
|
||||
|
||||
def CheckCursorDescriptionNoRow(self):
|
||||
"""
|
||||
|
@ -298,7 +298,7 @@ class ObjectAdaptationTests(unittest.TestCase):
|
|||
def CheckCasterIsUsed(self):
|
||||
self.cur.execute("select ?", (4,))
|
||||
val = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(type(val), float)
|
||||
self.assertEqual(type(val), float)
|
||||
|
||||
class BinaryConverterTests(unittest.TestCase):
|
||||
def convert(s):
|
||||
|
@ -315,7 +315,7 @@ class BinaryConverterTests(unittest.TestCase):
|
|||
def CheckBinaryInputForConverter(self):
|
||||
testdata = "abcdefg" * 10
|
||||
result = self.con.execute('select ? as "x [bin]"', (buffer(zlib.compress(testdata)),)).fetchone()[0]
|
||||
self.failUnlessEqual(testdata, result)
|
||||
self.assertEqual(testdata, result)
|
||||
|
||||
class DateTimeTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -332,14 +332,14 @@ class DateTimeTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(d) values (?)", (d,))
|
||||
self.cur.execute("select d from test")
|
||||
d2 = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(d, d2)
|
||||
self.assertEqual(d, d2)
|
||||
|
||||
def CheckSqliteTimestamp(self):
|
||||
ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0)
|
||||
self.cur.execute("insert into test(ts) values (?)", (ts,))
|
||||
self.cur.execute("select ts from test")
|
||||
ts2 = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(ts, ts2)
|
||||
self.assertEqual(ts, ts2)
|
||||
|
||||
def CheckSqlTimestamp(self):
|
||||
# The date functions are only available in SQLite version 3.1 or later
|
||||
|
@ -351,22 +351,22 @@ class DateTimeTests(unittest.TestCase):
|
|||
self.cur.execute("insert into test(ts) values (current_timestamp)")
|
||||
self.cur.execute("select ts from test")
|
||||
ts = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(type(ts), datetime.datetime)
|
||||
self.failUnlessEqual(ts.year, now.year)
|
||||
self.assertEqual(type(ts), datetime.datetime)
|
||||
self.assertEqual(ts.year, now.year)
|
||||
|
||||
def CheckDateTimeSubSeconds(self):
|
||||
ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0, 500000)
|
||||
self.cur.execute("insert into test(ts) values (?)", (ts,))
|
||||
self.cur.execute("select ts from test")
|
||||
ts2 = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(ts, ts2)
|
||||
self.assertEqual(ts, ts2)
|
||||
|
||||
def CheckDateTimeSubSecondsFloatingPoint(self):
|
||||
ts = sqlite.Timestamp(2004, 2, 14, 7, 15, 0, 510241)
|
||||
self.cur.execute("insert into test(ts) values (?)", (ts,))
|
||||
self.cur.execute("select ts from test")
|
||||
ts2 = self.cur.fetchone()[0]
|
||||
self.failUnlessEqual(ts, ts2)
|
||||
self.assertEqual(ts, ts2)
|
||||
|
||||
def suite():
|
||||
sqlite_type_suite = unittest.makeSuite(SqliteTypeTests, "Check")
|
||||
|
|
|
@ -160,28 +160,28 @@ class FunctionTests(unittest.TestCase):
|
|||
cur = self.con.cursor()
|
||||
cur.execute("select returntext()")
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(type(val), unicode)
|
||||
self.failUnlessEqual(val, "foo")
|
||||
self.assertEqual(type(val), unicode)
|
||||
self.assertEqual(val, "foo")
|
||||
|
||||
def CheckFuncReturnUnicode(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select returnunicode()")
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(type(val), unicode)
|
||||
self.failUnlessEqual(val, u"bar")
|
||||
self.assertEqual(type(val), unicode)
|
||||
self.assertEqual(val, u"bar")
|
||||
|
||||
def CheckFuncReturnInt(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select returnint()")
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(type(val), int)
|
||||
self.failUnlessEqual(val, 42)
|
||||
self.assertEqual(type(val), int)
|
||||
self.assertEqual(val, 42)
|
||||
|
||||
def CheckFuncReturnFloat(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select returnfloat()")
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(type(val), float)
|
||||
self.assertEqual(type(val), float)
|
||||
if val < 3.139 or val > 3.141:
|
||||
self.fail("wrong value")
|
||||
|
||||
|
@ -189,15 +189,15 @@ class FunctionTests(unittest.TestCase):
|
|||
cur = self.con.cursor()
|
||||
cur.execute("select returnnull()")
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(type(val), type(None))
|
||||
self.failUnlessEqual(val, None)
|
||||
self.assertEqual(type(val), type(None))
|
||||
self.assertEqual(val, None)
|
||||
|
||||
def CheckFuncReturnBlob(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select returnblob()")
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(type(val), buffer)
|
||||
self.failUnlessEqual(val, buffer("blob"))
|
||||
self.assertEqual(type(val), buffer)
|
||||
self.assertEqual(val, buffer("blob"))
|
||||
|
||||
def CheckFuncException(self):
|
||||
cur = self.con.cursor()
|
||||
|
@ -206,37 +206,37 @@ class FunctionTests(unittest.TestCase):
|
|||
cur.fetchone()
|
||||
self.fail("should have raised OperationalError")
|
||||
except sqlite.OperationalError, e:
|
||||
self.failUnlessEqual(e.args[0], 'user-defined function raised exception')
|
||||
self.assertEqual(e.args[0], 'user-defined function raised exception')
|
||||
|
||||
def CheckParamString(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select isstring(?)", ("foo",))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckParamInt(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select isint(?)", (42,))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckParamFloat(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select isfloat(?)", (3.14,))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckParamNone(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select isnone(?)", (None,))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckParamBlob(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select isblob(?)", (buffer("blob"),))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
class AggregateTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -280,7 +280,7 @@ class AggregateTests(unittest.TestCase):
|
|||
cur.execute("select nostep(t) from test")
|
||||
self.fail("should have raised an AttributeError")
|
||||
except AttributeError, e:
|
||||
self.failUnlessEqual(e.args[0], "AggrNoStep instance has no attribute 'step'")
|
||||
self.assertEqual(e.args[0], "AggrNoStep instance has no attribute 'step'")
|
||||
|
||||
def CheckAggrNoFinalize(self):
|
||||
cur = self.con.cursor()
|
||||
|
@ -289,7 +289,7 @@ class AggregateTests(unittest.TestCase):
|
|||
val = cur.fetchone()[0]
|
||||
self.fail("should have raised an OperationalError")
|
||||
except sqlite.OperationalError, e:
|
||||
self.failUnlessEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
|
||||
self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
|
||||
|
||||
def CheckAggrExceptionInInit(self):
|
||||
cur = self.con.cursor()
|
||||
|
@ -298,7 +298,7 @@ class AggregateTests(unittest.TestCase):
|
|||
val = cur.fetchone()[0]
|
||||
self.fail("should have raised an OperationalError")
|
||||
except sqlite.OperationalError, e:
|
||||
self.failUnlessEqual(e.args[0], "user-defined aggregate's '__init__' method raised error")
|
||||
self.assertEqual(e.args[0], "user-defined aggregate's '__init__' method raised error")
|
||||
|
||||
def CheckAggrExceptionInStep(self):
|
||||
cur = self.con.cursor()
|
||||
|
@ -307,7 +307,7 @@ class AggregateTests(unittest.TestCase):
|
|||
val = cur.fetchone()[0]
|
||||
self.fail("should have raised an OperationalError")
|
||||
except sqlite.OperationalError, e:
|
||||
self.failUnlessEqual(e.args[0], "user-defined aggregate's 'step' method raised error")
|
||||
self.assertEqual(e.args[0], "user-defined aggregate's 'step' method raised error")
|
||||
|
||||
def CheckAggrExceptionInFinalize(self):
|
||||
cur = self.con.cursor()
|
||||
|
@ -316,37 +316,37 @@ class AggregateTests(unittest.TestCase):
|
|||
val = cur.fetchone()[0]
|
||||
self.fail("should have raised an OperationalError")
|
||||
except sqlite.OperationalError, e:
|
||||
self.failUnlessEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
|
||||
self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
|
||||
|
||||
def CheckAggrCheckParamStr(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select checkType('str', ?)", ("foo",))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckAggrCheckParamInt(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select checkType('int', ?)", (42,))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckAggrCheckParamFloat(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select checkType('float', ?)", (3.14,))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckAggrCheckParamNone(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select checkType('None', ?)", (None,))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckAggrCheckParamBlob(self):
|
||||
cur = self.con.cursor()
|
||||
cur.execute("select checkType('blob', ?)", (buffer("blob"),))
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 1)
|
||||
self.assertEqual(val, 1)
|
||||
|
||||
def CheckAggrCheckAggrSum(self):
|
||||
cur = self.con.cursor()
|
||||
|
@ -354,7 +354,7 @@ class AggregateTests(unittest.TestCase):
|
|||
cur.executemany("insert into test(i) values (?)", [(10,), (20,), (30,)])
|
||||
cur.execute("select mysum(i) from test")
|
||||
val = cur.fetchone()[0]
|
||||
self.failUnlessEqual(val, 60)
|
||||
self.assertEqual(val, 60)
|
||||
|
||||
def authorizer_cb(action, arg1, arg2, dbname, source):
|
||||
if action != sqlite.SQLITE_SELECT:
|
||||
|
|
Loading…
Reference in New Issue