dhruv's wiki

Ch 1: Getting started with Pytest

Pytest options

pytest -v tasks/test_four.py::test_asdict
# specify a test function
pytest -k "asdict" --collect-only
# -k is for expressions
# --collect-only shows the tests to be run, without running themx
-x
# exit on first fail
--tb=no
# turn off stack trace
--maxfail=2
# like -x but you can specify the number of tests
# that have to fail before exiting
-s or --capture=no
# turns off output capture for failing tests
# lets hooking into set_trace
-l or --showlocals
--lf
# last failed
-ff
# failed first
--disable-pytest-warnings
# disable warnings
-r
# show extra test summary info as specified by chars
# show extra test summary info as specified by chars
# (f)ailed, (E)error, (s)skipped, (x)failed, (X)passed,
# (p)passed, (P)passed with output, (a)all except pP.