Fix Module 'pytest' has no 'config' member

pytest.config is created dynamically.

See: https://pagure.io/freeipa/issue/7758
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Christian Heimes
2018-11-09 11:29:56 +01:00
parent 713607769e
commit 1e569c4f46

View File

@@ -71,7 +71,8 @@ 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):
config = pytest.config # pylint: disable=no-member
if 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
@@ -84,7 +85,8 @@ def check_ipaclient_unittests(reason="Skip in ipaclient unittest mode"):
def check_no_ipaapi(reason="Skip tests that needs an IPA API"):
"""Call this in a package to skip the package in no-ipaapi mode
"""
if pytest.config.getoption('skip_ipaapi', False):
config = pytest.config # pylint: disable=no-member
if config.getoption('skip_ipaapi', False):
if PYTEST_VERSION[0] >= 3:
# pylint: disable=unexpected-keyword-arg
raise pytest.skip.Exception(reason, allow_module_level=True)