pytest
’s useful command-line flags for debugging (source).
-lf
: Runs just the tests that failed last-ff
: Runs all the tests, starting with the last failed-x
: Stops the tests session after the first failure--maxfail=num
: Stops the tests after num failures-nf
: Runs all the tests, ordered by file modification time--sw
: Stops the tests at the first failure. Starts the tests at the last failure next time--sw-skip
: Same as –sw, but skips the first failure-v
: Displays all the test names, passing or failing--tb=[auto/long/short/line/native/no]
: Controls the traceback style-l
: Displays local variables alongside the stacktrace--pdb
: Starts an interactive debugging session at the point of failure--trace
: Starts the pdb source-code debugger immediately when running each test--pdbcls
: Uses alternatives to pdb