From d4d57f44508c5e6e5af3c566d99ddaa367b2eaa8 Mon Sep 17 00:00:00 2001 From: Geert Hesselink Date: Sat, 9 Nov 2024 20:26:46 +0100 Subject: [PATCH] apply only to testing env --- features/environment.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/features/environment.py b/features/environment.py index 750b45a0..a85e01e0 100644 --- a/features/environment.py +++ b/features/environment.py @@ -64,21 +64,21 @@ def after_scenario(context, scenario): # Given steps may introduce an arbitrary amount of stackframes. # we need to clean them up before behave starts appending new ones. - if context.failed: - execution_mode = context.config.userdata.get('execution_mode') - if execution_mode and execution_mode == 'ExecutionMode.TESTING': - if not 'Behave errors' in context.step.error_message: #exclude behave output from exception logging + execution_mode = context.config.userdata.get('execution_mode') + if execution_mode and execution_mode == 'ExecutionMode.TESTING': + if context.failed: + if context.step.error_message and not 'Behave errors' in context.step.error_message: #exclude behave output from exception logging context.caught_exceptions.append(ExceptionSummary.from_context(context)) - elif execution_mode and execution_mode == ExecutionMode.PRODUCTION: - pass # send emails to vs team + context.scenario_outcome_state.append((len(context.gherkin_outcomes)-1, {'scenario': context.scenario.name, 'last_step': context.scenario.steps[-1]})) + elif execution_mode and execution_mode == 'ExecutionMode.PRODUCTION': + if context.failed: + pass # write message to VS team old_outcomes = getattr(context, 'gherkin_outcomes', []) while context._stack[0].get('@layer') == 'attribute': context._pop() # preserve the outcomes to be serialized to DB in after_feature() context.gherkin_outcomes = old_outcomes - context.scenario_outcome_state[len(context.gherkin_outcomes)] = {'scenario': scenario.name, - 'last_step': scenario.steps[-1]} @@ -155,7 +155,7 @@ def get_or_create_instance_when_set(spf_id): def update_outcomes_with_scenario_data(context, outcomes): for outcome_index, outcome in enumerate(outcomes): sls = next((data for idx, data in context.scenario_outcome_state if idx == outcome_index), None) - + if sls is not None: outcome['scenario'] = sls['scenario'] outcome['last_step'] = sls['last_step'].name