mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
Modernize sqlite3 tests
Update current tests that use old pattern with assertRaises to make them more maintainable.
This commit is contained in:
parent
0e1d6802ff
commit
1003b34c71
6 changed files with 62 additions and 257 deletions
|
@ -170,14 +170,8 @@ class RegressionTests(unittest.TestCase):
|
|||
|
||||
con = sqlite.connect(":memory:")
|
||||
cur = Cursor(con)
|
||||
try:
|
||||
with self.assertRaises(sqlite.ProgrammingError):
|
||||
cur.execute("select 4+5").fetchall()
|
||||
self.fail("should have raised ProgrammingError")
|
||||
except sqlite.ProgrammingError:
|
||||
pass
|
||||
except:
|
||||
self.fail("should have raised ProgrammingError")
|
||||
|
||||
|
||||
def CheckStrSubclass(self):
|
||||
"""
|
||||
|
@ -196,13 +190,8 @@ class RegressionTests(unittest.TestCase):
|
|||
pass
|
||||
|
||||
con = Connection(":memory:")
|
||||
try:
|
||||
with self.assertRaises(sqlite.ProgrammingError):
|
||||
cur = con.cursor()
|
||||
self.fail("should have raised ProgrammingError")
|
||||
except sqlite.ProgrammingError:
|
||||
pass
|
||||
except:
|
||||
self.fail("should have raised ProgrammingError")
|
||||
|
||||
def CheckCursorRegistration(self):
|
||||
"""
|
||||
|
@ -223,13 +212,8 @@ class RegressionTests(unittest.TestCase):
|
|||
cur.executemany("insert into foo(x) values (?)", [(3,), (4,), (5,)])
|
||||
cur.execute("select x from foo")
|
||||
con.rollback()
|
||||
try:
|
||||
with self.assertRaises(sqlite.InterfaceError):
|
||||
cur.fetchall()
|
||||
self.fail("should have raised InterfaceError")
|
||||
except sqlite.InterfaceError:
|
||||
pass
|
||||
except:
|
||||
self.fail("should have raised InterfaceError")
|
||||
|
||||
def CheckAutoCommit(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue