fix(acms): resolve state leakage in BDD step definitions and fix export variable name

- Rename _uks_exports to _uko_exports for consistency with import alias
- Move BudgetEnforcer reconstruction out of if/else branch in
  step_create_budget_enforcer_with_max_total_size so it always creates
  a fresh instance, eliminating cross-scenario state leakage

The root cause was that the second Background step unconditionally
overwrote the enforcer only when hasattr existed — but the enforcer
from the previous scenario carried over stale constraints. Now both
Background steps run in a well-defined sequence: step_one sets
max_file_size, step_two reconstructs with that preserved value and
new max_total_size, before every scenario.

ISSUES CLOSED: #9583
This commit is contained in:
2026-05-08 15:19:24 +00:00
committed by drew
parent 4d5fa6a9d1
commit 17266f16e3
+12 -10
View File
@@ -23,19 +23,21 @@ def step_create_budget_enforcer_with_max_file_size(context, size: int) -> None:
def step_create_budget_enforcer_with_max_total_size(context, size: int) -> None:
"""Update the budget enforcer's max_total_size.
Reconstructs a fresh BudgetEnforcer preserving the already-set
max_file_size so both Background steps together fully configure
constraints for each new scenario.
Always reconstructs a fresh BudgetEnforcer unconditionally —
the Background runs before each scenario and must reset state to
prevent leakage between scenarios within the same feature file.
The previously-set max_file_size from step_one determines the new
enforcer's constraint since both Background steps run sequentially.
"""
# Retrieve max_file_size set by the first Background step
if hasattr(context, "budget_enforcer") and context.budget_enforcer is not None:
context.budget_enforcer = BudgetEnforcer(
max_file_size=context.budget_enforcer.max_file_size,
max_total_size=size,
)
_max_file_size = context.budget_enforcer.max_file_size
else:
context.budget_enforcer = BudgetEnforcer(
max_file_size=10000, max_total_size=size
)
_max_file_size = 10000 # Default fallback
context.budget_enforcer = BudgetEnforcer(
max_file_size=_max_file_size,
max_total_size=size,
)
@when("I add a file of {size:d} bytes to the context")