Skip to content

Instantly share code, notes, and snippets.

@hpk42
Created October 10, 2013 20:51
Show Gist options
  • Save hpk42/6925467 to your computer and use it in GitHub Desktop.
Save hpk42/6925467 to your computer and use it in GitHub Desktop.
# content of conftest.py
import pytest
@pytest.mark.tryfirst
def pytest_pyfunc_call(pyfuncitem):
marker = pyfuncitem.get_marker("skip_if_eval")
if marker is not None:
class Mapping:
def __getitem__(self, name):
if name not in pyfuncitem.fixturenames:
raise KeyError
return pyfuncitem._request.getfuncargvalue(name)
expr = marker.args[0]
if eval(expr, {}, Mapping()):
pytest.skip("skipped because of expression %r" % expr)
# content of test file
import pytest
@pytest.mark.skip_if_eval("tmpdir.basename")
def test_hello(tmpdir):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment