Configuration¶
The PriorityConfig dataclass controls all behavior
of behave-priority. It is immutable (frozen) and validated at construction
time.
- class behave_priority.config.PriorityConfig(order=False, reverse=False, priority_tag=None, stop_after_failures=None, stop_on_critical=False, critical_tag='critical', default_priority=999, report=False, report_format='text', parallel_coord=False)[source]¶
Bases:
objectImmutable configuration for priority execution.
All configuration is programmatic — no CLI flags.
- Variables:
order – Sort scenarios by priority (highest first).
reverse – Reverse sort order (lowest priority first).
priority_tag – Tag name to run first (e.g.
"smoke").stop_after_failures – Stop after N failed scenarios, or None to disable.
stop_on_critical – Stop if any critical scenario fails.
critical_tag – Tag name that marks a scenario as critical.
default_priority – Priority for scenarios without a priority tag.
report – Print execution report after run.
report_format – Output format for the report (
"text","json", or"csv").parallel_coord – Enable cross-process fail-fast coordination via
BEHAVE_PRIORITY_COORD_DIRenv var. When True and the env var is set, workers share failure state via a file-based coordinator.
- Raises:
ValueError – If
stop_after_failuresis not a positive integer (or None), ifcritical_tagorpriority_tagis an empty string, ifdefault_priorityis negative, or ifreport_formatis not one of"text","json","csv".
Configuration Fields¶
Field |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
Sort scenarios by priority (highest first). When |
|
|
|
Reverse sort order. When |
|
|
|
Tag name to run first (e.g. |
|
|
|
Stop after N failed scenarios. |
|
|
|
Stop execution if any scenario tagged |
|
|
|
Tag name that marks a scenario as critical. Both the tag and the
|
|
|
|
Priority assigned to scenarios without any priority tag. Must be non-negative. |
|
|
|
Print the execution report after the run via
|
|
|
|
Output format for the report. |
|
|
|
Enable cross-process fail-fast coordination via the
|
Validation¶
The following validations are performed at construction time:
stop_after_failuresmust be a positive integer orNone(booleans and floats are rejected).critical_tagmust not be an empty string.priority_tagmust not be an empty string if provided (Noneis valid).default_prioritymust be non-negative.report_formatmust be one of"text","json","csv".
Invalid values raise ValueError with a descriptive message.
Examples¶
Basic priority ordering:
from behave_priority import PriorityConfig
config = PriorityConfig(order=True)
Priority ordering with fail-fast:
config = PriorityConfig(
order=True,
stop_after_failures=3,
report=True,
)
Smoke tests first, stop on critical failure:
config = PriorityConfig(
order=True,
priority_tag="smoke",
stop_on_critical=True,
critical_tag="critical",
report=True,
)
Reversed order (highest priority number first):
config = PriorityConfig(order=True, reverse=True)
Custom default priority:
config = PriorityConfig(order=True, default_priority=100)
Immutability¶
PriorityConfig is a frozen dataclass with slots=True. Once created,
its fields cannot be modified:
config = PriorityConfig(order=True)
config.order = False # Raises FrozenInstanceError
This ensures that configuration remains consistent throughout the test run.