Brian Okken
1 min readNov 14, 2016

--

pytest --durations=0 — Show all times for tests and setup and teardown

pytest --durations=1 — Just show me the slowest

pytest --durations=10 — Slowest 10, with times, … etc.

Example with first example code, since the scenario is that we know one test is slow, but we don’t know which one, or how slow:

> pytest --durations=1
========= test session starts ===================
platform win32 — Python 3.5.2, pytest-3.0.4, py-1.4.31, pluggy-0.4.0
collected 2 items
test_this.py ..
================ slowest 1 test durations =================
0.50s call test_this.py::SlowTestCase::test_should_run_slow
================ 2 passed in 0.52 seconds ================

--

--

Brian Okken

Host of @TestAndCode (@testpodcast) and @PythonBytes. Author of “Python Testing with pytest”. Lean TDD advocate, Agile heckler. Python, C++.