Mercurial > p > roundup > code
diff test/test_mysql.py @ 5109:43a1f7fe39f5
Improved work-around for pytest markers bug
The previous fix was only a partial solution. Any test class sharing a
parent with, and appearing after, a skipped test class was being skipped
(not just other test classes using the skip/skipif marker). Now only
tests that should be skipped will be skipped, the rest should run as
normal.
| author | John Kristensen <john@jerrykan.com> |
|---|---|
| date | Tue, 28 Jun 2016 15:39:38 +1000 |
| parents | 37d1e24fb941 |
| children | efb34cbdba7c |
line wrap: on
line diff
--- a/test/test_mysql.py Mon Jun 27 22:10:45 2016 -0400 +++ b/test/test_mysql.py Tue Jun 28 15:39:38 2016 +1000 @@ -40,19 +40,21 @@ self.module.db_nuke(config) -# FIX: workaround for a bug in pytest.mark.skipif(): +# FIX: workaround for a bug in pytest.mark.skip(): # https://github.com/pytest-dev/pytest/issues/568 +from .pytest_patcher import mark_class + if not have_backend('mysql'): - skip_mysql = pytest.mark.skip( - reason='Skipping MySQL tests: backend not available') + skip_mysql = mark_class(pytest.mark.skip( + reason='Skipping MySQL tests: backend not available')) else: try: import MySQLdb mysqlOpener.module.db_exists(config) skip_mysql = lambda func, *args, **kwargs: func except (MySQLdb.MySQLError, DatabaseError) as msg: - skip_mysql = pytest.mark.skip( - reason='Skipping MySQL tests: %s' % str(msg)) + skip_mysql = mark_class(pytest.mark.skip( + reason='Skipping MySQL tests: %s' % str(msg))) @skip_mysql
