Replace more boilerplate code with modern unittest features in sqlite3 tests
This commit is contained in:
parent
f5b1af6df5
commit
48b5c98e6e
|
@ -335,8 +335,7 @@ class CursorTests(unittest.TestCase):
|
||||||
def CheckTotalChanges(self):
|
def CheckTotalChanges(self):
|
||||||
self.cu.execute("insert into test(name) values ('foo')")
|
self.cu.execute("insert into test(name) values ('foo')")
|
||||||
self.cu.execute("insert into test(name) values ('foo')")
|
self.cu.execute("insert into test(name) values ('foo')")
|
||||||
if self.cx.total_changes < 2:
|
self.assertLess(2, self.cx.total_changes, msg='total changes reported wrong value')
|
||||||
self.fail("total changes reported wrong value")
|
|
||||||
|
|
||||||
# Checks for executemany:
|
# Checks for executemany:
|
||||||
# Sequences are required by the DB-API, iterators
|
# Sequences are required by the DB-API, iterators
|
||||||
|
|
|
@ -61,8 +61,8 @@ class CollationTests(unittest.TestCase):
|
||||||
) order by x collate mycoll
|
) order by x collate mycoll
|
||||||
"""
|
"""
|
||||||
result = con.execute(sql).fetchall()
|
result = con.execute(sql).fetchall()
|
||||||
if result[0][0] != "c" or result[1][0] != "b" or result[2][0] != "a":
|
self.assertEqual(result, [('c',), ('b',), ('a',)],
|
||||||
self.fail("the expected order was not returned")
|
msg='the expected order was not returned')
|
||||||
|
|
||||||
con.create_collation("mycoll", None)
|
con.create_collation("mycoll", None)
|
||||||
with self.assertRaises(sqlite.OperationalError) as cm:
|
with self.assertRaises(sqlite.OperationalError) as cm:
|
||||||
|
|
|
@ -134,17 +134,11 @@ class RegressionTests(unittest.TestCase):
|
||||||
def CheckErrorMsgDecodeError(self):
|
def CheckErrorMsgDecodeError(self):
|
||||||
# When porting the module to Python 3.0, the error message about
|
# When porting the module to Python 3.0, the error message about
|
||||||
# decoding errors disappeared. This verifies they're back again.
|
# decoding errors disappeared. This verifies they're back again.
|
||||||
failure = None
|
with self.assertRaises(sqlite.OperationalError) as cm:
|
||||||
try:
|
|
||||||
self.con.execute("select 'xxx' || ? || 'yyy' colname",
|
self.con.execute("select 'xxx' || ? || 'yyy' colname",
|
||||||
(bytes(bytearray([250])),)).fetchone()
|
(bytes(bytearray([250])),)).fetchone()
|
||||||
failure = "should have raised an OperationalError with detailed description"
|
msg = "Could not decode to UTF-8 column 'colname' with text 'xxx"
|
||||||
except sqlite.OperationalError as e:
|
self.assertIn(msg, str(cm.exception))
|
||||||
msg = e.args[0]
|
|
||||||
if not msg.startswith("Could not decode to UTF-8 column 'colname' with text 'xxx"):
|
|
||||||
failure = "OperationalError did not have expected description text"
|
|
||||||
if failure:
|
|
||||||
self.fail(failure)
|
|
||||||
|
|
||||||
def CheckRegisterAdapter(self):
|
def CheckRegisterAdapter(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue