I am using skipIf()
from unittest
for skipping tests in certain conditions.
@unittest.skipIf(condition), "this is why I skipped them!")
How do I tell py.test
to display skipping conditions?
I know that for unittest I need to enable the verbose mode (-v
) but the same parameter added to py.test increase the verbosity by still does not display the skip reasons.
The most common reason for the test cases getting skipped with Selenium using TestNG is if your methods are dependent on other method and a method you depend on is failed.
You can use the xfail marker to indicate that you expect a test to fail: @pytest.
The simplest way to skip a test is to mark it with the skip decorator which may be passed an optional reason . It is also possible to skip imperatively during test execution or setup by calling the pytest. skip(reason) function. This is useful when it is not possible to evaluate the skip condition during import time.
When you run py.test, you can pass -rsx
to report skipped tests.
From py.test --help
:
-r chars show extra test summary info as specified by chars (f)ailed, (E)error, (s)skipped, (x)failed, (X)passed.
Also see this part of the documentation about skipping: http://doc.pytest.org/en/latest/skipping.html
Short answer:
pytest -rs
This will show extra information of skipped tests.
Detailed answer:
To complement @ToddWilson's answer, the following chars have been added: p
and P
(2.9.0), a
(4.1.0) and A
(4.5.0). The detailed information about skipped and xfailed tests is not shown by default in order to avoid cluttering the output. You can use the -r
flag among with the following chars:
f
)ailedE
)rrors
)kippedx
)failedX
)passedp
)assedP
)assed with outputa
)ll except passed (p/P)A
)ll.Warnings are enabled by default, and the default value is fE
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With