We can now use the grains dictionary on pytest.mark.skipif

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-12-18 11:23:23 +00:00 committed by Pedro Algarvio
parent 0239a3885b
commit db054f6232

View file

@ -1,11 +1,3 @@
"""
:codeauthor: Pedro Algarvio (pedro@algarvio.me)
tests.conftest
~~~~~~~~~~~~~~
Prepare py.test for our test suite
"""
# pylint: disable=wrong-import-order,wrong-import-position,3rd-party-local-module-not-gated
# pylint: disable=redefined-outer-name,invalid-name,3rd-party-module-not-gated
@ -489,6 +481,19 @@ def pytest_runtest_protocol(item, nextitem):
del used_fixture_defs
def pytest_markeval_namespace(config):
"""
Called when constructing the globals dictionary used for evaluating string conditions in xfail/skipif markers.
This is useful when the condition for a marker requires objects that are expensive or impossible to obtain during
collection time, which is required by normal boolean conditions.
:param config: The pytest config object.
:returns: A dictionary of additional globals to add.
"""
return {"grains": _grains_for_marker()}
# <---- PyTest Tweaks ------------------------------------------------------------------------------------------------