pytest 3.x compatibility

pytest 3.x does no longer support plain pytest.skip() on module level.

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Christian Heimes
2017-03-27 18:03:14 +02:00
committed by Pavel Vomacka
parent 0ba0c07813
commit dd6b72e418
7 changed files with 28 additions and 20 deletions
+16
View File
@@ -61,6 +61,22 @@ if six.PY3:
unicode = str
PYTEST_VERSION = tuple(int(v) for v in pytest.__version__.split('.'))
def check_ipaclient_unittests(reason="Skip in ipaclient unittest mode"):
"""Call this in a package to skip the package in ipaclient-unittest mode
"""
if pytest.config.getoption('ipaclient_unittests', False):
if PYTEST_VERSION[0] >= 3:
# pytest 3+ does no longer allow pytest.skip() on module level
# pylint: disable=unexpected-keyword-arg
raise pytest.skip.Exception(reason, allow_module_level=True)
# pylint: enable=unexpected-keyword-arg
else:
raise pytest.skip(reason)
class TempDir(object):
def __init__(self):
self.__path = tempfile.mkdtemp(prefix='ipa.tests.')