API Reference — Transformations¶
All transformations modify the model in place. Use copy.deepcopy if you need to preserve the original.
Functions¶
rename_tag(project, old_name, new_name)¶
Rename a tag across all features, rules, and scenarios.
| Parameter | Type | Description |
|---|---|---|
project |
Project |
The project to modify |
old_name |
str |
Current tag name (with @) |
new_name |
str |
New tag name (with @) |
rename_scenario(project, old_name, new_name)¶
Rename a scenario by exact name match.
from behave_model import rename_scenario
rename_scenario(project, "Successful login", "User logs in successfully")
sort_tags(project)¶
Sort tags alphabetically in all features, rules, and scenarios.
sort_features(project, key=None)¶
Sort features by name (default) or a custom key function.
from behave_model import sort_features
# Sort by name
sort_features(project)
# Sort by filename
sort_features(project, key=lambda f: f.location.filename)
| Parameter | Type | Description |
|---|---|---|
project |
Project |
The project to modify |
key |
Callable \| None |
Sort key function (default: feature name) |
sort_scenarios(project)¶
Sort scenarios alphabetically within each feature and rule.
normalize_whitespace(project)¶
Normalize whitespace in all names, descriptions, and step text.
remove_tag(project, name)¶
Remove a tag from all features, rules, and scenarios.
add_tag_to_feature(project, feature_name, tag_name)¶
Add a tag to a specific feature by name.
| Parameter | Type | Description |
|---|---|---|
project |
Project |
The project to modify |
feature_name |
str |
Exact feature name |
tag_name |
str |
Tag to add (with @) |