pytest Cheat Sheet

Running

pytest

will collect every test in a folder and execute them.

Select test case

you can specify the tests to be run by module::test_function or by module::test_class::test_method e.g.

pytest test_sort_algortihms.py::TestSortAlgorithms::test_python_sorted

Execution time

If you pass --durations=0 execution time for all tests will be reported.

Verbosity

can be increased with the -v option