Skip to content

Commit

Permalink
Fixes #771 allure-behave formatter crash with behave v1.2.7.dev5 (#798)
Browse files Browse the repository at this point in the history
Co-authored-by: Maxim <[email protected]>
  • Loading branch information
ercaronte and delatrie authored Mar 14, 2024
1 parent 2a71e7f commit d759bc5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 9 additions & 2 deletions allure-behave/src/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
from allure_behave.utils import get_fullname
from allure_behave.utils import TEST_PLAN_SKIP_REASON
from allure_behave.utils import get_hook_name
import behave
from packaging import version

BEHAVE_1_2_7_OR_GREATER = version.parse(behave.__version__) > version.parse("1.2.6")


class AllureListener:
Expand Down Expand Up @@ -97,8 +101,11 @@ def stop_test(self, parent_uuid, uuid, name, context, exc_type, exc_val, exc_tb)
self.stop_scenario(context['scenario'])

def stop_scenario(self, scenario):
should_run = (scenario.should_run_with_tags(self.behave_config.tags) and
scenario.should_run_with_name_select(self.behave_config))
if BEHAVE_1_2_7_OR_GREATER:
should_run = scenario.should_run_with_tags(self.behave_config.tag_expression)
else:
should_run = scenario.should_run_with_tags(self.behave_config.tags)
should_run = should_run and scenario.should_run_with_name_select(self.behave_config)
should_drop_skipped_by_option = scenario.status == 'skipped' and not self.behave_config.show_skipped
should_drop_excluded = self.hide_excluded and (scenario.skip_reason == TEST_PLAN_SKIP_REASON or not should_run)

Expand Down
3 changes: 0 additions & 3 deletions tests/allure_behave/behave_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@ def load_step_definitions(self, extra_step_paths=None):
behave.step_registry.registry = self.step_registry = StepRegistry()
step_globals = {
"use_step_matcher": matchers.use_step_matcher,
"step_matcher": matchers.step_matcher,
}

# To support the decorators (e.g., @given) with no imports
setup_step_decorators(step_globals, self.step_registry)

default_matcher = matchers.current_matcher
for step in self.__steps:
step_module_globals = step_globals.copy()
exec(step, step_module_globals)
matchers.current_matcher = default_matcher

def load_features(self):
self.features.extend(
Expand Down

0 comments on commit d759bc5

Please sign in to comment.