summaryrefslogtreecommitdiff
path: root/Lib/sqlite3/test/regression.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-06-12 22:34:49 +0300
committerBerker Peksag <berker.peksag@gmail.com>2016-06-12 22:34:49 +0300
commit1003b34c71d53ccb88ae2768aaba503ae6b5bc16 (patch)
tree31cf203e12c8091b1b5fa0040dd143ff76aa647f /Lib/sqlite3/test/regression.py
parent0e1d6802ff03666bced6548e75b8459c88c2b720 (diff)
downloadcpython-git-1003b34c71d53ccb88ae2768aaba503ae6b5bc16.tar.gz
Modernize sqlite3 tests
Update current tests that use old pattern with assertRaises to make them more maintainable.
Diffstat (limited to 'Lib/sqlite3/test/regression.py')
-rw-r--r--Lib/sqlite3/test/regression.py22
1 files changed, 3 insertions, 19 deletions
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
index 11adb300d8..85ace84d75 100644
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -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):
"""