mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
change deprecated unittest method calls into their proper names.
This commit is contained in:
parent
0d3fa833a1
commit
04cecafce1
7 changed files with 151 additions and 151 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue