Reputation: 1399
I am using py.test -rfs
to get additional reports on failed and skipped tests.
There are two ways by which a test gets skipped:
pytest.skip(msg)
from inside of a test case@pytest.mark.skipif(condition, msg)
In the final report, if I use pytest.skip()
I get lines int the following form:
path/testmodule:linenumber: message`
The name of the test case (which is not there) would be great but this way it's certainly good enough.
But when I use pytest.mark.skipif()
, what I get is this:
SKIP [1] /usr/lib/python2.7/dist-packages/_pytest/skipping.py:132: message
Not even the test module name. The path to always the same line from inside py.test ifself is not really helpful.
I certainly could put the name of the test case into the message but if there is a more elegant way of getting the report better, it would be great. Does anyone know of that?
Upvotes: 3
Views: 2187
Reputation: 17751
Instead of -rfs
, you should use -v
:
$ py.test -v t.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.8 -- py-1.4.23 -- pytest-2.6.0 -- /usr/bin/python
collected 2 items
t.py@3::test_1 SKIPPED
t.py@7::test_2 SKIPPED
========================== 2 skipped in 0.01 seconds ==========================
The above output comes from the following file:
import pytest
def test_1():
pytest.skip('msg')
@pytest.mark.skipif(True, reason='msg')
def test_2():
pass
Upvotes: 4