diff test/test_mysql.py @ 5038:c977f3530944

Work-around for pytest.mark.skipif() bug There is a pytest bug that can cause all test classes marked with the skipif() decorator that inherit a common class to be skipped if one of the skipif() conditions is True. See: https://github.com/pytest-dev/pytest/issues/568
author John Kristensen <john@jerrykan.com>
date Mon, 07 Sep 2015 23:24:33 +1000
parents 364c54991861
children 37d1e24fb941
line wrap: on
line diff
--- a/test/test_mysql.py	Fri Aug 21 13:08:02 2015 +1000
+++ b/test/test_mysql.py	Mon Sep 07 23:24:33 2015 +1000
@@ -40,20 +40,17 @@
         self.module.db_nuke(config)
 
 
+# FIX: workaround for a bug in pytest.mark.skipif():
+#   https://github.com/pytest-dev/pytest/issues/568
 if not have_backend('mysql'):
-    SKIP_MYSQL = True
-    SKIP_MYSQL_REASON = 'Skipping MySQL tests: not enabled'
+    skip_mysql = pytest.skip('Skipping MySQL tests: backend not available')
 else:
     try:
         import MySQLdb
         mysqlOpener.module.db_exists(config)
-        SKIP_MYSQL = False
-        SKIP_MYSQL_REASON = ''
+        skip_mysql = lambda func, *args, **kwargs: func
     except (MySQLdb.MySQLError, DatabaseError) as msg:
-        SKIP_MYSQL = True
-        SKIP_MYSQL_REASON = 'Skipping MySQL tests: %s' % str(msg)
-
-skip_mysql = pytest.mark.skipif(SKIP_MYSQL, reason=SKIP_MYSQL_REASON)
+        skip_mysql = pytest.skip('Skipping MySQL tests: %s' % str(msg))
 
 
 @skip_mysql

Roundup Issue Tracker: http://roundup-tracker.org/