OnCallReady

Commands

pytest - simple powerful testing with Python

pytest [-q] [-v] [-x] [-k EXPR] [FILE[::TEST]]...

Options you will use

-v
One line per test with PASSED/FAILED.
-q
Quiet: dots only.
-x
Stop at the first failure.
-k EXPR
Only run tests whose name contains EXPR ("not EXPR" to exclude).
-s
Do not capture output: print() shows up live (--capture=no).
--maxfail=N
Stop after N failures.
-m MARKEXPR
Only run tests matching the marker expression.
--lf, --last-failed
Rerun only the tests that failed last time.
--tb=STYLE
Traceback style: auto, long, short, line, no.
-r CHARS
Short summary of the given outcomes: f failed, E error, s skipped, a all but passes.
--junitxml=PATH
Write a JUnit XML report (what CI dashboards read).
--cov=PATH
Measure coverage of PATH (pytest-cov).

Examples

$ pytest

Collect test_*.py / _test.py under the current directory and run every test_ function.

$ pytest test_checks.py::test_timeout -v

Run one test.

Gotchas

Try pytest in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.