checks.doctests.DoctestsCheck

checks.doctests.DoctestsCheck()

Run doctests via pytest –doctest-modules.

Executes all doctests embedded in module docstrings and reports failures. A file that pytest cannot import is left out and named.

Attributes

name :

The check identifier (“doctests”).

description :

Human-readable description of this check.

rules :

The codes of the findings this check can report.

hints :

What to do about each of them, one sentence for each code.

Methods

Name Description
run Run doctests for the package.

run

checks.doctests.DoctestsCheck.run(package_path, config)

Run doctests for the package.

Parameters

package_path : Path

Path to the package directory to check.

config : dict[str, Any]

Configuration dictionary for this check. Supports args (list[str]) for additional pytest args and timeout (seconds) to override the default of 120.

Returns

: CheckResult

A CheckResult with:

: CheckResult
  • OK status if all doctests pass
: CheckResult
  • WARNING status if pytest is installed but could not run
: CheckResult
  • ERROR status if some doctests fail, pytest times out or an invalid option is set
: CheckResult
  • SKIPPED status if pytest is not installed (“tool-missing”), if the package has no doctests or there is no package to collect them from (“not-applicable”), or if no doctest ran and a file could not be imported (“import-failed”)
: CheckResult

Files that pytest could not import are counted in the message

: CheckResult

and named in the details. They change the status only when no

: CheckResult

doctest ran.