checks.tests.TestsCheck
checks.tests.TestsCheck()Run package tests and report results.
Executes the package’s test suite using the configured test runner (pytest by default) and reports pass/fail status. Supports pytest and unittest runners.
Attributes
name :-
The check identifier (“tests”).
description :-
Human-readable description of this check.
rules :-
The codes of the findings this check can report.
hints :-
What to do about each code.
Examples
Run tests with default settings (pytest):
>>> from pathlib import Path
>>> check = TestsCheck()
>>> result = check.run(Path("."), {"enabled": True})
>>> result.name
'tests'Configure to use unittest:
>>> config = {"enabled": True, "runner": "unittest"}
>>> result = check.run(Path("."), config)Pass additional pytest arguments:
>>> config = {"enabled": True, "args": ["-x", "--cov"]}
>>> result = check.run(Path("."), config)Methods
| Name | Description |
|---|---|
| run | Run tests and return results. |
run
checks.tests.TestsCheck.run(package_path, config)Run tests and return results.
Executes the test suite when the project has one, in any of the places the test_suite check looks. The test runner is determined by the runner config option.
Parameters
package_path : Path-
Path to the package directory containing tests.
config : dict[str, Any]-
Configuration dictionary with options: - runner (str): “pytest” or “unittest” (default: “pytest”) - args (list[str]): Additional arguments for the runner - timeout (float): Time limit in seconds (default: 300)
Returns
: CheckResult-
A CheckResult with:
: CheckResult-
- OK status if all tests pass
: CheckResult-
- WARNING status if no tests are collected, or the runner is installed but could not run
: CheckResult-
- ERROR status if tests fail, cannot be collected or time out, or an unknown runner or an invalid option is configured
: CheckResult-
- SKIPPED status if the test runner is not installed (“tool-missing”), or the project has no tests (“prerequisite-failed”), which the test_suite check reports