[Python-checkins] cpython (3.5): Mark tests as skipped when a SQLite version is not supported

berker.peksag python-checkins at python.org
Tue Jun 14 07:19:15 EDT 2016


https://hg.python.org/cpython/rev/b1d27f36b8e1
changeset:   102026:b1d27f36b8e1
branch:      3.5
parent:      102024:38c1ccdfd38a
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Tue Jun 14 14:19:02 2016 +0300
summary:
  Mark tests as skipped when a SQLite version is not supported

files:
  Lib/sqlite3/test/dbapi.py        |   4 ++--
  Lib/sqlite3/test/regression.py   |   3 +--
  Lib/sqlite3/test/transactions.py |  12 ++++--------
  Lib/sqlite3/test/types.py        |   6 ++----
  4 files changed, 9 insertions(+), 16 deletions(-)


diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -177,9 +177,9 @@
             with self.assertRaises(sqlite.OperationalError):
                 cx.execute('insert into test(id) values(1)')
 
+    @unittest.skipIf(sqlite.sqlite_version_info >= (3, 3, 1),
+                     'needs sqlite versions older than 3.3.1')
     def CheckSameThreadErrorOnOldVersion(self):
-        if sqlite.sqlite_version_info >= (3, 3, 1):
-            self.skipTest('test needs sqlite3 versions older than 3.3.1')
         with self.assertRaises(sqlite.NotSupportedError) as cm:
             sqlite.connect(':memory:', check_same_thread=False)
         self.assertEqual(str(cm.exception), 'shared connections not available')
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -84,9 +84,8 @@
             cur.execute("select 1 x union select " + str(i))
         con.close()
 
+    @unittest.skipIf(sqlite.sqlite_version_info < (3, 2, 2), 'needs sqlite 3.2.2 or newer')
     def CheckOnConflictRollback(self):
-        if sqlite.sqlite_version_info < (3, 2, 2):
-            return
         con = sqlite.connect(":memory:")
         con.execute("create table foo(x, unique(x) on conflict rollback)")
         con.execute("insert into foo(x) values (1)")
diff --git a/Lib/sqlite3/test/transactions.py b/Lib/sqlite3/test/transactions.py
--- a/Lib/sqlite3/test/transactions.py
+++ b/Lib/sqlite3/test/transactions.py
@@ -111,25 +111,21 @@
         res = self.cur2.fetchall()
         self.assertEqual(len(res), 1)
 
+    @unittest.skipIf(sqlite.sqlite_version_info < (3, 2, 2),
+                     'test hangs on sqlite versions older than 3.2.2')
     def CheckRaiseTimeout(self):
-        if sqlite.sqlite_version_info < (3, 2, 2):
-            # This will fail (hang) on earlier versions of sqlite.
-            # Determine exact version it was fixed. 3.2.1 hangs.
-            return
         self.cur1.execute("create table test(i)")
         self.cur1.execute("insert into test(i) values (5)")
         with self.assertRaises(sqlite.OperationalError):
             self.cur2.execute("insert into test(i) values (5)")
 
+    @unittest.skipIf(sqlite.sqlite_version_info < (3, 2, 2),
+                     'test hangs on sqlite versions older than 3.2.2')
     def CheckLocking(self):
         """
         This tests the improved concurrency with pysqlite 2.3.4. You needed
         to roll back con2 before you could commit con1.
         """
-        if sqlite.sqlite_version_info < (3, 2, 2):
-            # This will fail (hang) on earlier versions of sqlite.
-            # Determine exact version it was fixed. 3.2.1 hangs.
-            return
         self.cur1.execute("create table test(i)")
         self.cur1.execute("insert into test(i) values (5)")
         with self.assertRaises(sqlite.OperationalError):
diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py
--- a/Lib/sqlite3/test/types.py
+++ b/Lib/sqlite3/test/types.py
@@ -340,11 +340,9 @@
         ts2 = self.cur.fetchone()[0]
         self.assertEqual(ts, ts2)
 
+    @unittest.skipIf(sqlite.sqlite_version_info < (3, 1),
+                     'the date functions are available on 3.1 or later')
     def CheckSqlTimestamp(self):
-        # The date functions are only available in SQLite version 3.1 or later
-        if sqlite.sqlite_version_info < (3, 1):
-            return
-
         # SQLite's current_timestamp uses UTC time, while datetime.datetime.now() uses local time.
         now = datetime.datetime.now()
         self.cur.execute("insert into test(ts) values (current_timestamp)")

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list