diff --git a/allure-behave/src/listener.py b/allure-behave/src/listener.py index dab47789..927c72a8 100644 --- a/allure-behave/src/listener.py +++ b/allure-behave/src/listener.py @@ -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: @@ -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) diff --git a/tests/allure_behave/behave_runner.py b/tests/allure_behave/behave_runner.py index 0dd0a37a..defb1849 100644 --- a/tests/allure_behave/behave_runner.py +++ b/tests/allure_behave/behave_runner.py @@ -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(