Skip to content

Commit 9f8b821

Browse files
committed
fix: copy scenario steps in accuracy to avoid modifications
1 parent 44fe533 commit 9f8b821

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

toolium/utils/ai_utils/accuracy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import re
2121
from behave.model import ScenarioOutline
2222
from behave.model_core import Status
23+
from copy import deepcopy
2324

2425

2526
def get_accuracy_and_executions_from_tags(tags, accuracy_data_len=None):
@@ -89,9 +90,14 @@ def patch_scenario_with_accuracy(context, scenario, data_key_suffix, accuracy=0.
8990
def scenario_run_with_accuracy(context, scenario_run, scenario, *args, **kwargs):
9091
# Execute the scenario multiple times and count passed executions
9192
passed_executions = 0
93+
# Copy scenario steps to avoid modifications in each execution, especially when using behave variables
94+
# transformation, like map_param and replace_param methods
95+
orig_steps = deepcopy(scenario.steps)
9296
for execution in range(executions):
9397
context.logger.info(f"Running accuracy scenario execution ({execution+1}/{executions})")
9498
store_execution_data(context, execution, data_key_suffix)
99+
# Restore original steps before each execution
100+
scenario.steps = deepcopy(orig_steps)
95101
if not scenario_run(*args, **kwargs):
96102
passed_executions += 1
97103
status = "PASSED"

0 commit comments

Comments
 (0)