pytest_test_categories.reporting¶
Test size reporting functionality.
This module provides classes and functions for generating reports about test size distribution and execution statistics. It supports both summary and detailed reports, with information about test sizes, execution times, and status.
- Example usage:
pytest –test-size-report pytest –test-size-report=detailed pytest –test-size-report path/to/tests/
Classes¶
Record of a performance baseline violation. |
|
Generator for test size reports. |
Module Contents¶
- class pytest_test_categories.reporting.BaselineViolation(/, **data)[source]¶
Bases:
pydantic.BaseModelRecord of a performance baseline violation.
Tracks when a test exceeds its custom performance baseline, which is stricter than the category’s default time limit.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- class pytest_test_categories.reporting.TestSizeReport(/, **data)[source]¶
Bases:
pydantic.BaseModelGenerator for test size reports.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- add_baseline_violation(nodeid, baseline, category_limit, actual)[source]¶
Record a baseline violation for a test.
- add_test(nodeid, size, duration=None, outcome='passed')[source]¶
Add a test to the report.
- Parameters:
nodeid (str) – The pytest node ID of the test
size (pytest_test_categories.types.TestSize | None) – The test size category, or None if unsized
duration (float | None) – The test execution time in seconds, if available
outcome (str) – The test outcome (passed, failed, etc.)
- Return type:
None
- exceeds_time_limit(nodeid, size)[source]¶
Check if a test exceeds its time limit based on size.
- Parameters:
nodeid (str)
size (pytest_test_categories.types.TestSize | None)
- Return type:
- write_basic_report(terminalreporter)[source]¶
Write a basic summary report to the terminal.
- Parameters:
terminalreporter (pytest.TerminalReporter)
- Return type:
None
- write_detailed_report(terminalreporter)[source]¶
Write a detailed report to the terminal.
- Parameters:
terminalreporter (pytest.TerminalReporter)
- Return type:
None
- baseline_violations: dict[str, BaselineViolation] = None[source]¶
- sized_tests: collections.defaultdict[pytest_test_categories.types.TestSize, list[str]] = None[source]¶