re #329 add test for skipif failure when you pass boolean without the reason. add emphasize to the docs.

--HG--
branch : 329-skipif-requires-expression-as-a-string
This commit is contained in:
Anatoly Bubenkov 2013-07-06 18:54:24 +02:00
parent 31421cb6d7
commit 214793f697
2 changed files with 33 additions and 20 deletions

View File

@ -44,6 +44,7 @@ During test function setup the condition ("sys.version_info >= (3,3)") is
checked. If it evaluates to True, the test function will be skipped
with the specified reason. Note that pytest enforces specifying a reason
in order to report meaningful "skip reasons" (e.g. when using ``-rs``).
If the condition is a string, it will be evaluated as python expression.
You can share skipif markers between modules. Consider this test module::

View File

@ -100,6 +100,18 @@ class TestEvaluator:
expl = ev.getexplanation()
assert expl == "condition: not hasattr(os, 'murks')"
def test_marked_skip_with_not_string(self, testdir):
item = testdir.getitem("""
import pytest
@pytest.mark.skipif(False)
def test_func():
pass
""")
ev = MarkEvaluator(item, 'skipif')
with pytest.raises(pytest.fail.Exception) as exc:
assert ev.istrue()
assert """Failed: you need to specify reason=STRING when using booleans as conditions.""" in exc.value.msg
def test_skipif_class(self, testdir):
item, = testdir.getitems("""
import pytest