Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #771 allure-behave formatter crash with behave v1.2.7.dev5 #798

Merged
merged 6 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading