Skip to content

Commit 39e322a

Browse files
Fix Pytest4.1+ warnings about pytest.config
pytest.config global is deprecated since Pytest4.1: https://docs.pytest.org/en/latest/deprecations.html#pytest-config-global pytest-dev/pytest#3050 Fixes: https://pagure.io/freeipa/issue/7981 Signed-off-by: Stanislav Levin <[email protected]>
1 parent 02d6fc7 commit 39e322a

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ipatests/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def pytest_configure(config):
8383

8484
# always run doc tests
8585
config.option.doctestmodules = True
86+
# pytest.config global is deprecated
87+
pytest.ipa_pytestconfig = config
8688

8789

8890
def pytest_addoption(parser):
@@ -135,11 +137,11 @@ def pytest_runtest_setup(item):
135137
get_marker = item.get_marker # pylint: disable=no-member
136138
if get_marker('skip_ipaclient_unittest'):
137139
# pylint: disable=no-member
138-
if pytest.config.option.ipaclient_unittests:
140+
if item.config.option.ipaclient_unittests:
139141
pytest.skip("Skip in ipaclient unittest mode")
140142
if get_marker('needs_ipaapi'):
141143
# pylint: disable=no-member
142-
if pytest.config.option.skip_ipaapi:
144+
if item.config.option.skip_ipaapi:
143145
pytest.skip("Skip tests that needs an IPA API")
144146

145147

ipatests/test_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ def test_eq(self):
152152
assert (None == self.klass()) is True
153153

154154

155-
def test_assert_deepequal():
155+
def test_assert_deepequal(pytestconfig):
156156
f = util.assert_deepequal
157157
try: # pylint: disable=no-member
158-
pretty = pytest.config.getoption("pretty_print")
158+
pretty = pytestconfig.getoption("pretty_print")
159159
except (AttributeError, ValueError):
160160
pretty = False
161161

ipatests/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
def check_ipaclient_unittests(reason="Skip in ipaclient unittest mode"):
7676
"""Call this in a package to skip the package in ipaclient-unittest mode
7777
"""
78-
config = pytest.config # pylint: disable=no-member
78+
config = pytest.ipa_pytestconfig # pylint: disable=no-member
7979
if config.getoption('ipaclient_unittests', False):
8080
if PYTEST_VERSION[0] >= 3:
8181
# pytest 3+ does no longer allow pytest.skip() on module level
@@ -89,7 +89,7 @@ def check_ipaclient_unittests(reason="Skip in ipaclient unittest mode"):
8989
def check_no_ipaapi(reason="Skip tests that needs an IPA API"):
9090
"""Call this in a package to skip the package in no-ipaapi mode
9191
"""
92-
config = pytest.config # pylint: disable=no-member
92+
config = pytest.ipa_pytestconfig # pylint: disable=no-member
9393
if config.getoption('skip_ipaapi', False):
9494
if PYTEST_VERSION[0] >= 3:
9595
# pylint: disable=unexpected-keyword-arg
@@ -389,7 +389,7 @@ def assert_deepequal(expected, got, doc='', stack=tuple()):
389389
their elements does not matter.
390390
"""
391391
try:
392-
pretty_print = pytest.config.getoption("pretty_print")
392+
pretty_print = pytest.ipa_pytestconfig.getoption("pretty_print")
393393
except (AttributeError, ValueError):
394394
pretty_print = False
395395

0 commit comments

Comments
 (0)