Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest_markeval_namespace hook. #8124

Merged

Conversation

bluetech
Copy link
Member

@bluetech bluetech commented Dec 12, 2020

This is same as #7695 but rebased, one tiny style issue and changed from testdir -> pytester.

Closes #7695


Add a new hook , pytest_markeval_namespace which should return a dictionary.
This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers.

Pseudo example

conftest.py:

   def pytest_markeval_namespace():
       return {"color": "red"}

test_func.py:

   @pytest.mark.skipif("color == 'blue'", reason="Color is not red")
   def test_func():
       assert False

Add a new hook , `pytest_markeval_namespace` which should return a dictionary.
This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers.

Pseudo example

``conftest.py``:

.. code-block:: python
   def pytest_markeval_namespace():
       return {"color": "red"}
``test_func.py``:

.. code-block:: python
   @pytest.mark.skipif("color == 'blue'", reason="Color is not red")
   def test_func():
       assert False
@bluetech
Copy link
Member Author

Merging per @nicoddemus's approval in #7695. Thanks @s0undt3ch!

@bluetech bluetech merged commit 95e0e19 into pytest-dev:master Dec 12, 2020
@bluetech bluetech deleted the s0undt3ch-feature/skip-context-hook branch December 12, 2020 17:23
@s0undt3ch
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants