Modernize sqlite3 tests

Update current tests that use old pattern with assertRaises
to make them more maintainable.
diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py
index 8a4bbab..4075045 100644
--- a/Lib/sqlite3/test/userfunctions.py
+++ b/Lib/sqlite3/test/userfunctions.py
@@ -162,11 +162,8 @@
         self.con.close()
 
     def CheckFuncErrorOnCreate(self):
-        try:
+        with self.assertRaises(sqlite.OperationalError):
             self.con.create_function("bla", -100, lambda x: 2*x)
-            self.fail("should have raised an OperationalError")
-        except sqlite.OperationalError:
-            pass
 
     def CheckFuncRefCount(self):
         def getfunc():
@@ -231,12 +228,10 @@
 
     def CheckFuncException(self):
         cur = self.con.cursor()
-        try:
+        with self.assertRaises(sqlite.OperationalError) as cm:
             cur.execute("select raiseexception()")
             cur.fetchone()
-            self.fail("should have raised OperationalError")
-        except sqlite.OperationalError as e:
-            self.assertEqual(e.args[0], 'user-defined function raised exception')
+        self.assertEqual(str(cm.exception), 'user-defined function raised exception')
 
     def CheckParamString(self):
         cur = self.con.cursor()
@@ -312,55 +307,42 @@
         pass
 
     def CheckAggrErrorOnCreate(self):
-        try:
+        with self.assertRaises(sqlite.OperationalError):
             self.con.create_function("bla", -100, AggrSum)
-            self.fail("should have raised an OperationalError")
-        except sqlite.OperationalError:
-            pass
 
     def CheckAggrNoStep(self):
         cur = self.con.cursor()
-        try:
+        with self.assertRaises(AttributeError) as cm:
             cur.execute("select nostep(t) from test")
-            self.fail("should have raised an AttributeError")
-        except AttributeError as e:
-            self.assertEqual(e.args[0], "'AggrNoStep' object has no attribute 'step'")
+        self.assertEqual(str(cm.exception), "'AggrNoStep' object has no attribute 'step'")
 
     def CheckAggrNoFinalize(self):
         cur = self.con.cursor()
-        try:
+        with self.assertRaises(sqlite.OperationalError) as cm:
             cur.execute("select nofinalize(t) from test")
             val = cur.fetchone()[0]
-            self.fail("should have raised an OperationalError")
-        except sqlite.OperationalError as e:
-            self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
+        self.assertEqual(str(cm.exception), "user-defined aggregate's 'finalize' method raised error")
 
     def CheckAggrExceptionInInit(self):
         cur = self.con.cursor()
-        try:
+        with self.assertRaises(sqlite.OperationalError) as cm:
             cur.execute("select excInit(t) from test")
             val = cur.fetchone()[0]
-            self.fail("should have raised an OperationalError")
-        except sqlite.OperationalError as e:
-            self.assertEqual(e.args[0], "user-defined aggregate's '__init__' method raised error")
+        self.assertEqual(str(cm.exception), "user-defined aggregate's '__init__' method raised error")
 
     def CheckAggrExceptionInStep(self):
         cur = self.con.cursor()
-        try:
+        with self.assertRaises(sqlite.OperationalError) as cm:
             cur.execute("select excStep(t) from test")
             val = cur.fetchone()[0]
-            self.fail("should have raised an OperationalError")
-        except sqlite.OperationalError as e:
-            self.assertEqual(e.args[0], "user-defined aggregate's 'step' method raised error")
+        self.assertEqual(str(cm.exception), "user-defined aggregate's 'step' method raised error")
 
     def CheckAggrExceptionInFinalize(self):
         cur = self.con.cursor()
-        try:
+        with self.assertRaises(sqlite.OperationalError) as cm:
             cur.execute("select excFinalize(t) from test")
             val = cur.fetchone()[0]
-            self.fail("should have raised an OperationalError")
-        except sqlite.OperationalError as e:
-            self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
+        self.assertEqual(str(cm.exception), "user-defined aggregate's 'finalize' method raised error")
 
     def CheckAggrCheckParamStr(self):
         cur = self.con.cursor()
@@ -433,22 +415,14 @@
         pass
 
     def test_table_access(self):
-        try:
+        with self.assertRaises(sqlite.DatabaseError) as cm:
             self.con.execute("select * from t2")
-        except sqlite.DatabaseError as e:
-            if not e.args[0].endswith("prohibited"):
-                self.fail("wrong exception text: %s" % e.args[0])
-            return
-        self.fail("should have raised an exception due to missing privileges")
+        self.assertIn('prohibited', str(cm.exception))
 
     def test_column_access(self):
-        try:
+        with self.assertRaises(sqlite.DatabaseError) as cm:
             self.con.execute("select c2 from t1")
-        except sqlite.DatabaseError as e:
-            if not e.args[0].endswith("prohibited"):
-                self.fail("wrong exception text: %s" % e.args[0])
-            return
-        self.fail("should have raised an exception due to missing privileges")
+        self.assertIn('prohibited', str(cm.exception))
 
 class AuthorizerRaiseExceptionTests(AuthorizerTests):
     @staticmethod