From 04cecafce10abc8906a96aa16c0a7a87d9fb8227 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 4 Jul 2009 08:32:15 +0000 Subject: change deprecated unittest method calls into their proper names. --- Lib/sqlite3/test/dbapi.py | 92 +++++++++++++++++++-------------------- Lib/sqlite3/test/factory.py | 60 ++++++++++++------------- Lib/sqlite3/test/hooks.py | 10 ++--- Lib/sqlite3/test/regression.py | 4 +- Lib/sqlite3/test/transactions.py | 20 ++++----- Lib/sqlite3/test/types.py | 60 ++++++++++++------------- Lib/sqlite3/test/userfunctions.py | 56 ++++++++++++------------ 7 files changed, 151 insertions(+), 151 deletions(-) diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py index d276a33..4ce8906 100644 --- a/Lib/sqlite3/test/dbapi.py +++ b/Lib/sqlite3/test/dbapi.py @@ -44,39 +44,39 @@ class ModuleTests(unittest.TestCase): "Warning is not a subclass of Exception") def CheckError(self): - self.failUnless(issubclass(sqlite.Error, Exception), + self.assertTrue(issubclass(sqlite.Error, Exception), "Error is not a subclass of Exception") 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") @@ -126,16 +126,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): @@ -227,7 +227,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): @@ -240,13 +240,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): class D(dict): @@ -256,7 +256,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')") @@ -290,7 +290,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): """ @@ -299,12 +299,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')") @@ -377,24 +377,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 @@ -407,27 +407,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]) @@ -440,7 +440,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: @@ -651,7 +651,7 @@ class ExtensionTests(unittest.TestCase): """) cur.execute("select i from a") res = cur.fetchone()[0] - self.failUnlessEqual(res, 5) + self.assertEqual(res, 5) def CheckScriptErrorIncomplete(self): con = sqlite.connect(":memory:") @@ -661,7 +661,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:") @@ -671,26 +671,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): diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py index 345d5b3..1adab2f 100644 --- a/Lib/sqlite3/test/factory.py +++ b/Lib/sqlite3/test/factory.py @@ -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 = "Österreich" row = self.con.execute("select ?", (austria,)).fetchone() - self.failUnless(type(row[0]) == str, "type of row[0] must be unicode") + self.assertTrue(type(row[0]) == str, "type of row[0] must be unicode") def CheckString(self): self.con.text_factory = bytes austria = "Österreich" row = self.con.execute("select ?", (austria,)).fetchone() - self.failUnless(type(row[0]) == bytes, "type of row[0] must be bytes") - self.failUnless(row[0] == austria.encode("utf-8"), "column must equal original data in UTF-8") + self.assertTrue(type(row[0]) == bytes, "type of row[0] must be bytes") + 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: str(x, "utf-8", "ignore") austria = "Österreich" row = self.con.execute("select ?", (austria,)).fetchone() - self.failUnless(type(row[0]) == str, "type of row[0] must be unicode") - self.failUnless(row[0].endswith("reich"), "column must contain original data") + self.assertTrue(type(row[0]) == str, "type of row[0] must be unicode") + self.assertTrue(row[0].endswith("reich"), "column must contain original data") def CheckOptimizedUnicode(self): self.con.text_factory = sqlite.OptimizedUnicode @@ -183,8 +183,8 @@ class TextFactoryTests(unittest.TestCase): germany = "Deutchland" a_row = self.con.execute("select ?", (austria,)).fetchone() d_row = self.con.execute("select ?", (germany,)).fetchone() - self.failUnless(type(a_row[0]) == str, "type of non-ASCII row must be str") - self.failUnless(type(d_row[0]) == str, "type of ASCII-only row must be str") + self.assertTrue(type(a_row[0]) == str, "type of non-ASCII row must be str") + self.assertTrue(type(d_row[0]) == str, "type of ASCII-only row must be str") def tearDown(self): self.con.close() diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py index c15c7be..a6161fa 100644 --- a/Lib/sqlite3/test/hooks.py +++ b/Lib/sqlite3/test/hooks.py @@ -37,7 +37,7 @@ class CollationTests(unittest.TestCase): con.create_collation("X", 42) self.fail("should have raised a TypeError") except TypeError as 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 as 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") diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py index d056aae..2e61acf 100644 --- a/Lib/sqlite3/test/regression.py +++ b/Lib/sqlite3/test/regression.py @@ -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 diff --git a/Lib/sqlite3/test/transactions.py b/Lib/sqlite3/test/transactions.py index 0b6193b..c9f6125 100644 --- a/Lib/sqlite3/test/transactions.py +++ b/Lib/sqlite3/test/transactions.py @@ -58,14 +58,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)") @@ -74,7 +74,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)") @@ -83,7 +83,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)") @@ -92,24 +92,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): diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py index bde1645..8b1d780 100644 --- a/Lib/sqlite3/test/types.py +++ b/Lib/sqlite3/test/types.py @@ -39,27 +39,27 @@ class SqliteTypeTests(unittest.TestCase): self.cur.execute("insert into test(s) values (?)", ("Österreich",)) self.cur.execute("select s from test") row = self.cur.fetchone() - self.failUnlessEqual(row[0], "Österreich") + self.assertEqual(row[0], "Ö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): sample = b"Guglhupf" @@ -67,12 +67,12 @@ class SqliteTypeTests(unittest.TestCase): self.cur.execute("insert into test(b) values (?)", (val,)) self.cur.execute("select b from test") row = self.cur.fetchone() - self.failUnlessEqual(row[0], sample) + self.assertEqual(row[0], sample) def CheckUnicodeExecute(self): self.cur.execute("select 'Österreich'") row = self.cur.fetchone() - self.failUnlessEqual(row[0], "Österreich") + self.assertEqual(row[0], "Österreich") class DeclTypesTests(unittest.TestCase): class Foo: @@ -133,14 +133,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 @@ -148,7 +148,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 @@ -156,20 +156,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 @@ -177,14 +177,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 @@ -215,20 +215,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], sample) + self.assertEqual(row[0], sample) 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): @@ -257,28 +257,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, "") + self.assertEqual(val, "") # 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): """ @@ -310,7 +310,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): @@ -327,7 +327,7 @@ class BinaryConverterTests(unittest.TestCase): def CheckBinaryInputForConverter(self): testdata = b"abcdefg" * 10 result = self.con.execute('select ? as "x [bin]"', (memoryview(zlib.compress(testdata)),)).fetchone()[0] - self.failUnlessEqual(testdata, result) + self.assertEqual(testdata, result) class DateTimeTests(unittest.TestCase): def setUp(self): @@ -344,14 +344,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 @@ -363,22 +363,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") diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py index c165423..8bfc591 100644 --- a/Lib/sqlite3/test/userfunctions.py +++ b/Lib/sqlite3/test/userfunctions.py @@ -161,28 +161,28 @@ class FunctionTests(unittest.TestCase): cur = self.con.cursor() cur.execute("select returntext()") val = cur.fetchone()[0] - self.failUnlessEqual(type(val), str) - self.failUnlessEqual(val, "foo") + self.assertEqual(type(val), str) + self.assertEqual(val, "foo") def CheckFuncReturnUnicode(self): cur = self.con.cursor() cur.execute("select returnunicode()") val = cur.fetchone()[0] - self.failUnlessEqual(type(val), str) - self.failUnlessEqual(val, "bar") + self.assertEqual(type(val), str) + self.assertEqual(val, "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") @@ -190,15 +190,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), bytes) - self.failUnlessEqual(val, b"blob") + self.assertEqual(type(val), bytes) + self.assertEqual(val, b"blob") def CheckFuncException(self): cur = self.con.cursor() @@ -207,37 +207,37 @@ class FunctionTests(unittest.TestCase): cur.fetchone() self.fail("should have raised OperationalError") except sqlite.OperationalError as 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(?)", (memoryview(b"blob"),)) val = cur.fetchone()[0] - self.failUnlessEqual(val, 1) + self.assertEqual(val, 1) class AggregateTests(unittest.TestCase): def setUp(self): @@ -281,7 +281,7 @@ class AggregateTests(unittest.TestCase): cur.execute("select nostep(t) from test") self.fail("should have raised an AttributeError") except AttributeError as e: - self.failUnlessEqual(e.args[0], "'AggrNoStep' object has no attribute 'step'") + self.assertEqual(e.args[0], "'AggrNoStep' object has no attribute 'step'") def CheckAggrNoFinalize(self): cur = self.con.cursor() @@ -290,7 +290,7 @@ class AggregateTests(unittest.TestCase): val = cur.fetchone()[0] self.fail("should have raised an OperationalError") except sqlite.OperationalError as 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() @@ -299,7 +299,7 @@ class AggregateTests(unittest.TestCase): val = cur.fetchone()[0] self.fail("should have raised an OperationalError") except sqlite.OperationalError as 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() @@ -308,7 +308,7 @@ class AggregateTests(unittest.TestCase): val = cur.fetchone()[0] self.fail("should have raised an OperationalError") except sqlite.OperationalError as 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() @@ -317,37 +317,37 @@ class AggregateTests(unittest.TestCase): val = cur.fetchone()[0] self.fail("should have raised an OperationalError") except sqlite.OperationalError as 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', ?)", (memoryview(b"blob"),)) val = cur.fetchone()[0] - self.failUnlessEqual(val, 1) + self.assertEqual(val, 1) def CheckAggrCheckAggrSum(self): cur = self.con.cursor() @@ -355,7 +355,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: -- cgit v0.12