Skip to content

Commit d759bc5

Browse files
ercarontedelatrie
andauthored
Fixes #771 allure-behave formatter crash with behave v1.2.7.dev5 (#798)
Co-authored-by: Maxim <[email protected]>
1 parent 2a71e7f commit d759bc5

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

allure-behave/src/listener.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
from allure_behave.utils import get_fullname
2323
from allure_behave.utils import TEST_PLAN_SKIP_REASON
2424
from allure_behave.utils import get_hook_name
25+
import behave
26+
from packaging import version
27+
28+
BEHAVE_1_2_7_OR_GREATER = version.parse(behave.__version__) > version.parse("1.2.6")
2529

2630

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

99103
def stop_scenario(self, scenario):
100-
should_run = (scenario.should_run_with_tags(self.behave_config.tags) and
101-
scenario.should_run_with_name_select(self.behave_config))
104+
if BEHAVE_1_2_7_OR_GREATER:
105+
should_run = scenario.should_run_with_tags(self.behave_config.tag_expression)
106+
else:
107+
should_run = scenario.should_run_with_tags(self.behave_config.tags)
108+
should_run = should_run and scenario.should_run_with_name_select(self.behave_config)
102109
should_drop_skipped_by_option = scenario.status == 'skipped' and not self.behave_config.show_skipped
103110
should_drop_excluded = self.hide_excluded and (scenario.skip_reason == TEST_PLAN_SKIP_REASON or not should_run)
104111

tests/allure_behave/behave_runner.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,14 @@ def load_step_definitions(self, extra_step_paths=None):
7474
behave.step_registry.registry = self.step_registry = StepRegistry()
7575
step_globals = {
7676
"use_step_matcher": matchers.use_step_matcher,
77-
"step_matcher": matchers.step_matcher,
7877
}
7978

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

83-
default_matcher = matchers.current_matcher
8482
for step in self.__steps:
8583
step_module_globals = step_globals.copy()
8684
exec(step, step_module_globals)
87-
matchers.current_matcher = default_matcher
8885

8986
def load_features(self):
9087
self.features.extend(

0 commit comments

Comments
 (0)