Skip to content

pytest

pytest documentation

toolroom._stubs.pytest.Pytest

Bases: Tool[_R]

__call__

__call__(
    *args: str | PathLike[str],
    assert_: Value = ...,
    basetemp: Value = ...,
    cache_clear: Flag = ...,
    cache_show: Value = ...,
    capture: Value = ...,
    code_highlight: Flag = ...,
    collect_in_virtualenv: Flag = ...,
    collect_only: Flag = ...,
    color: Value = ...,
    confcutdir: Value = ...,
    config_file: Value = ...,
    continue_on_collection_errors: Flag = ...,
    cov: Value = ...,
    cov_append: Flag = ...,
    cov_branch: Flag = ...,
    cov_config: Value = ...,
    cov_context: Value = ...,
    cov_fail_under: Value = ...,
    cov_precision: Value = ...,
    cov_report: Value = ...,
    cov_reset: Flag = ...,
    debug: Value = ...,
    deselect: Value = ...,
    disable_plugin_autoload: Flag = ...,
    disable_warnings: Flag = ...,
    doctest_continue_on_failure: Flag = ...,
    doctest_glob: Value = ...,
    doctest_ignore_import_errors: Flag = ...,
    doctest_modules: Flag = ...,
    doctest_report: Flag = ...,
    durations: Value = ...,
    durations_min: Value = ...,
    exitfirst: Flag = ...,
    ff: Flag = ...,
    fixtures: Flag = ...,
    fixtures_per_test: Flag = ...,
    force_short_summary: Flag = ...,
    full_trace: Flag = ...,
    ignore: Value = ...,
    ignore_glob: Value = ...,
    import_mode: Flag = ...,
    junitprefix: Value = ...,
    junitxml: Value = ...,
    k: Value = ...,
    keep_duplicates: Flag = ...,
    lf: Flag = ...,
    lfnf: Flag = ...,
    log_auto_indent: Value = ...,
    log_cli_date_format: Value = ...,
    log_cli_format: Value = ...,
    log_cli_level: Value = ...,
    log_date_format: Value = ...,
    log_disable: Value = ...,
    log_file: Value = ...,
    log_file_date_format: Value = ...,
    log_file_format: Value = ...,
    log_file_level: Value = ...,
    log_file_mode: Flag = ...,
    log_format: Value = ...,
    log_level: Value = ...,
    m: Value = ...,
    markers: Flag = ...,
    max_warnings: Value = ...,
    maxfail: Value = ...,
    nf: Flag = ...,
    no_cov: Flag = ...,
    no_cov_on_fail: Flag = ...,
    no_fold_skipped: Flag = ...,
    no_header: Flag = ...,
    no_summary: Flag = ...,
    noconftest: Flag = ...,
    override_ini: Value = ...,
    p: Value = ...,
    pastebin: Value = ...,
    pdb: Flag = ...,
    pdbcls: Value = ...,
    pyargs: Flag = ...,
    pythonwarnings: Value = ...,
    quiet: Flag = ...,
    r: Value = ...,
    report_chars: Value = ...,
    rootdir: Value = ...,
    runxfail: Flag = ...,
    s: Flag = ...,
    setup_only: Flag = ...,
    setup_plan: Flag = ...,
    setup_show: Flag = ...,
    show_capture: Flag = ...,
    showlocals: Flag = ...,
    strict: Flag = ...,
    strict_config: Flag = ...,
    strict_markers: Flag = ...,
    sw: Flag = ...,
    sw_reset: Flag = ...,
    sw_skip: Flag = ...,
    tb: Value = ...,
    trace: Flag = ...,
    trace_config: Flag = ...,
    verbose: Flag = ...,
    verbosity: Value = ...,
    xfail_tb: Flag = ...,
    **flags: Any,
) -> _R

Run this verb.

Parameters:

Name Type Description Default
assert_ Value

Control assertion debugging tools.

...
basetemp Value

Base temporary directory for this test run.

...
cache_clear Flag

Remove all cache contents at start of test run.

...
cache_show Value

Show cache contents, don't perform collection or tests. Defaults to *.

...
capture Value

Per-test capturing method: one of fd|sys|no|tee-sys.

...
code_highlight Flag

Whether code should be highlighted (only if --color is also enabled).

...
collect_in_virtualenv Flag

Don't ignore tests in a local virtualenv directory.

...
collect_only Flag

Only collect tests, don't execute them.

...
color Value

Color terminal output (yes/no/auto).

...
confcutdir Value

Only load conftest.py's relative to specified dir.

...
config_file Value

Load configuration from FILE instead of trying to locate one of the implicit configuration files.

...
continue_on_collection_errors Flag

Force test execution even if collection errors occur.

...
cov Value

Path or package name to measure during execution (multi-allowed).

...
cov_append Flag

Do not delete coverage but append to current.

...
cov_branch Flag

Enable branch coverage.

...
cov_config Value

Config file for coverage.

...
cov_context Value

Dynamic contexts to use.

...
cov_fail_under Value

Fail if the total coverage is less than MIN.

...
cov_precision Value

Override the reporting precision.

...
cov_report Value

Type of report to generate: term, term-missing, annotate, html, xml, json, markdown, markdown-append, lcov (multi-allowed).

...
cov_reset Flag

Reset cov sources accumulated in options so far.

...
debug Value

Store internal tracing debug information in this log file.

...
deselect Value

Deselect item (via node id prefix) during collection (multi-allowed).

...
disable_plugin_autoload Flag

Disable plugin auto-loading through entry point packaging metadata. Added in 8.4.0.

...
disable_warnings Flag

Disable warnings summary.

...
doctest_continue_on_failure Flag

For a given doctest, continue to run after the first failure.

...
doctest_glob Value

Doctests file matching pattern, default: test*.txt.

...
doctest_ignore_import_errors Flag

Ignore doctest collection errors.

...
doctest_modules Flag

Run doctests in all .py modules.

...
doctest_report Flag

Choose another output format for diffs on doctest failure.

...
durations Value

Show N slowest setup/test durations (N=0 for all).

...
durations_min Value

Minimal duration in seconds for inclusion in slowest list.

...
exitfirst Flag

Exit instantly on first error or failed test.

...
ff Flag

Run all tests, but run the last failures first.

...
fixtures Flag

Show available fixtures, sorted by plugin appearance (fixtures with leading '_' are only shown with '-v').

...
fixtures_per_test Flag

Show fixtures per test.

...
force_short_summary Flag

Force condensed summary output regardless of verbosity level. Added in 8.4.0.

...
full_trace Flag

Don't cut any tracebacks.

...
ignore Value

Ignore path during collection (multi-allowed).

...
ignore_glob Value

Ignore path pattern during collection (multi-allowed).

...
import_mode Flag

Prepend/append to sys.path when importing test modules and conftest files.

...
junitprefix Value

Prepend prefix to classnames in junit-xml output.

...
junitxml Value

Create junit-xml style report file at given path.

...
k Value

Only run tests which match the given substring expression.

...
keep_duplicates Flag

Keep duplicate tests.

...
lf Flag

Rerun only the tests that failed at the last run (or all if none failed).

...
lfnf Flag

With --lf, determines whether to execute tests when there are no previously (known) failures or when no cached lastfailed data was found.

...
log_auto_indent Value

Auto-indent multiline messages passed to the logging module.

...
log_cli_date_format Value

Log date format used by the logging module.

...
log_cli_format Value

Log format used by the logging module.

...
log_cli_level Value

CLI logging level.

...
log_date_format Value

Log date format used by the logging module.

...
log_disable Value

Disable a logger by name. May be repeated: a list emits the flag once per item.

...
log_file Value

Path to a file when logging will be written to.

...
log_file_date_format Value

Log date format used by the logging module.

...
log_file_format Value

Log format used by the logging module.

...
log_file_level Value

Log file logging level.

...
log_file_mode Flag

Log file open mode.

...
log_format Value

Log format used by the logging module.

...
log_level Value

Level of messages to catch/display.

...
m Value

Only run tests matching given mark expression.

...
markers Flag

show markers (builtin, plugin and per-project ones).

...
max_warnings Value

Exit with error if all tests pass but the number of warnings exceeds this threshold. Added in 9.1.0.

...
maxfail Value

Exit after first num failures or errors.

...
nf Flag

Run tests from new files first, then the rest of the tests sorted by file mtime.

...
no_cov Flag

Disable coverage report completely (useful for debuggers).

...
no_cov_on_fail Flag

Do not report coverage if test run fails.

...
no_fold_skipped Flag

Do not fold skipped tests in short summary.

...
no_header Flag

Disable header.

...
no_summary Flag

Disable summary.

...
noconftest Flag

Don't load any conftest.py files.

...
override_ini Value

Override configuration option with "option=value" style, e.g. -o strict_xfail=True -o cache_dir=cache.

...
p Value

Early-load given plugin module name or entry point (multi-allowed).

...
pastebin Value

Send failed|all info to bpaste.net pastebin service.

...
pdb Flag

Start the interactive Python debugger on errors or KeyboardInterrupt.

...
pdbcls Value

Specify a custom interactive Python debugger for use with --pdb.For example: --pdbcls=IPython.terminal.debugger:TerminalPdb.

...
pyargs Flag

Try to interpret all arguments as Python packages.

...
pythonwarnings Value

Set which warnings to report, see -W option of Python itself.

...
quiet Flag

Decrease verbosity.

...
r Value

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. May be repeated: a list emits the flag once per item. Defaults to fE. Gone since 9.1.0.

...
report_chars Value

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. May be repeated: a list emits the flag once per item. Defaults to fE. Added in 9.1.0.

...
rootdir Value

Define root directory for tests.

...
runxfail Flag

Report the results of xfail tests as if they were not marked.

...
s Flag

Shortcut for --capture=no.

...
setup_only Flag

Only setup fixtures, do not execute tests.

...
setup_plan Flag

Show what fixtures and tests would be executed but don't execute anything.

...
setup_show Flag

Show setup of fixtures while executing tests.

...
show_capture Flag

Controls how captured stdout/stderr/log is shown on failed tests.

...
showlocals Flag

Show locals in tracebacks (disabled by default). showlocals=off emits --no-showlocals.

...
strict Flag

Enables the strict option.

...
strict_config Flag

Enables the strict_config option.

...
strict_markers Flag

Enables the strict_markers option.

...
sw Flag

Exit on test failure and continue from last failing test next time.

...
sw_reset Flag

Resets stepwise state, restarting the stepwise workflow. Added in 8.4.0.

...
sw_skip Flag

Ignore the first failing test but stop on the next failing test.

...
tb Value

Traceback print mode (auto/long/short/line/native/no).

...
trace Flag

Immediately break when running each test.

...
trace_config Flag

Trace considerations of conftest.py files.

...
verbose Flag

Increase verbosity.

...
verbosity Value

Set verbosity.

...
xfail_tb Flag

Show tracebacks for xfail (as long as --tb != no).

...