The test file or directory you want to run pytest on. If omitted, pytest will run all of the files of the form test_*.py or *_test.py in the current directory and its subdirectories
Options
Name
Description
--assert <Mode>
Control assertion debugging tools. 'plain' performs no assertion debugging. 'rewrite' (the default) rewrites assert statements in test modules on import to provide assert expression information
--basetemp <Directory>
Base temporary directory for this test run.(warning: this directory is removed if it exists)
-c <File>
Load configuration from `file` instead of trying to locate one of the implicit configuration files
--cache-clear
Remove all cache contents at start of test run
--cache-show [Glob]
Show cache contents, don't perform collection or tests. Optional argument: glob (default: '*')
--capture <Method>
Per-test capturing method
--code-highlight <Highlight>
Whether code should be highlighted (only if --color is also enabled)
--co, --collect-only
Only collect tests, don't execute them
--collect-in-virtualenv
Don't ignore tests in a local virtualenv directory
--color <Color>
Color terminal output
--confcutdir <Dir>
Only load conftest.py's relative to specified dir
--continue-on-collection-errors
Force test execution even if collection errors occur
--debug [Debug File Name]
Store internal tracing debug information in this log file. This file is opened with 'w' and truncated as a result, care advised. Defaults to 'pytestdebug.log'
--durations <N>
Show N slowest setup/test durations (N=0 for all)
--durations-min <N>
Minimal duration in seconds for inclusion in slowest list
--deselect <nodeid_prefix>
Repeatable ♾
--disable-warnings, --disable-pytest-warnings
Disable warnings summary
--doctest-continue-on-failure
For a given doctest, continue to run after the first failure
--doctest-ignore-import-errors
Ignore doctest ImportErrors
--doctest-modules
Run doctests in all .py modules
--doctest-report <Output format>
Choose another output format for diffs on doctest failure
Shows builtin and custom fixtures. Note that this command omits fixtures with leading _ unless the -v option is added
--fixtures-per-test
Show fixtures per test
--full-trace
Don't cut any tracebacks (default is to cut)
--help, -h
This shows help on command line and config-line options
--ignore <Path>
Repeatable ♾
--ignore-glob <Path>
Repeatable ♾
--import-mode <Mode>
Prepend/append to sys.path when importing test modules and conftest files, default is to prepend
--junit-xml <Path>
Create junit-xml style report file at given path
--junit-prefix <Str>
Prepend prefix to classnames in junit-xml output
-k <Expression>
Only run tests which match the given substring expression. An expression is a python evaluatable expression where all names are substring-matched against test names and their parent classes. Example: -k 'test_method or test_other' matches all test functions and classes whose name contains 'test_method' or 'test_other', while -k 'not test_method' matches those that don't contain 'test_method' in their names. -k 'not test_method and not test_other' will eliminate the matches. Additionally keywords are matched to classes and functions containing extra names in their 'extra_keyword_matches' set, as well as functions which have names assigned directly to them. The matching is case- insensitive
--keep-duplicates
Keep duplicate tests
--showlocals, -l
Show locals in tracebacks (disabled by default)
--last-failed-no-failures, --lfnf <Tests>
Which tests to run with no previously (known) failures
--last-failed, --lf
Rerun only the tests that failed at the last run (or all if none failed)
--log-auto-indent <Log Auto Indent Setting>
Auto-indent multiline messages passed to the logging module. Accepts true|on, false|off or an integer
--log-cli-level <Log CLI Level>
Cli logging level
--log-cli-format <Log CLI Format>
Log format as used by the logging module
--log-cli-date-format <Log CLI Date Format>
Log date format as used by the logging module
--log-date-format <Log Date Format>
Log date format as used by the logging module
--log-format <Log Format>
Log format as used by the logging module
--log-file <Log File Path>
Path to a file where logging will be written to
--log-file-level <Log File Level>
Log file logging level
--log-file-date-format <Log File Date Format>
Log date format as used by the logging module
--log-file-format <Log File Format>
Log format as used by the logging module
--log-level <Level>
Level of messages to catch/display. Not set by default, so it depends on the root/parent log handler's effective level, where it is `WARNING` by default
-m <Mark Expression>
Only run tests matching given mark expression
--markers
Show markers (builtin, plugin and per-project ones)
--maxfail <num>
Exit after first num failures or errors
--new-first, --nf
Run tests from new files first, then the rest of the tests sorted by file mtime
--noconftest
Don't load any conftest.py files
--no-header
Disable header
--no-summary
Disable summary
--override-ini, -o <Override INI>
Override ini option with `option=value` style`
-p <Plugin name>
Repeatable ♾
--pastebin <mode>
Send failed|all info to bpaste.net pastebin service
--pdb
Start the interactive Python debugger on errors or KeyboardInterrupt
--pdbcls <modulename:classname>
Specify a custom interactive Python debugger for use with --pdb
--pyargs
Try to interpret all arguments as python packages
--quiet, -q
Decrease verbosity
-r <chars>
Show extra test summary info as specified by chars: (f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed, (p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. (w)arnings are enabled by default (see --disable-warnings), 'N' can be used to reset the list. (default: 'fE')
--rootdir <Root Dir>
Define root directory for tests. Can be relative path: 'root_dir', './root_dir', 'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables:'$HOME/root_dir'
--runxfail
Report the results of xfail tests as if they were not marked
-s
Shortcut for --capture=no
--setup-only
Only setup fixtures, do not execute tests
--setup-show
Show setup of fixtures while executing tests
--setup-plan
Show what fixtures and tests would be executed but don't execute anything
--show-capture <Capture method>
Controls how captured stdout/stderr/log is shown on failed tests
--stepwise, --sw
Exit on test failure and continue from last failing test next time
--stepwise-skip, --sw-skip
Ignore the first failing test but stop on the next failing test
--strict
Alias to --strict-markers
--strict-config
Any warnings encountered while parsing the `pytest` section of the configuration file raise errors
--strict-markers
Markers not registered in the `markers` section of the configuration file raise errors
--tb <Traceback print mode>
Traceback print mode
--trace
Immediately break when running each test
--trace-config
Trace considerations of conftest.py files
--verbose, -v
Repeatable ♾
--verbosity <Verbosity level>
Set verbosity. Default is 0
--version, -V
Display pytest version and information about plugins. When given twice, also display information about plugins
--pythonwarnings, -W <Warnings to report>
Set which warnings to report, see -W option of python itself