Skip to content
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
14 changes: 7 additions & 7 deletions allure-pytest-bdd/features/outline.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ Feature: Scenario outline
And example_test.py with content:
"""
from pytest_bdd import scenario
from pytest_bdd import given, then, when
from pytest_bdd import given, then, when, parsers

@given("<first> step")
@given(parsers.parse("{first} step"))
def given_step(first):
pass

@when("do nothing")
def nope_step():
pass

@then("step with <second> param")
@then(parsers.parse("step with {second} param"))
def then_step(second):
pass

Expand All @@ -39,13 +39,13 @@ Feature: Scenario outline
Then allure report has result for "Outline example" scenario
Then this scenario has parameter "first" with value "Alpha"
Then this scenario has parameter "second" with value "1"
Then this scenario contains "Given <Alpha> step" step
Then this scenario contains "Then step with <1> param" step
Then this scenario contains "Given Alpha step" step
Then this scenario contains "Then step with 1 param" step

Then allure report has result for "Outline example" scenario
Then this scenario has parameter "first" with value "Bravo"
Then this scenario has parameter "second" with value "2"
Then this scenario contains "Given <Bravo> step" step
Then this scenario contains "Then step with <2> param" step
Then this scenario contains "Given Bravo step" step
Then this scenario contains "Then step with 2 param" step


2 changes: 1 addition & 1 deletion allure-pytest-bdd/src/pytest_bdd_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def pytest_bdd_before_step(self, request, feature, scenario, step, step_func):
parent_uuid = get_uuid(request.node.nodeid)
uuid = get_uuid(str(id(step)))
with self.lifecycle.start_step(parent_uuid=parent_uuid, uuid=uuid) as step_result:
step_result.name = get_step_name(request.node, step)
step_result.name = get_step_name(step)

@pytest.hookimpl
def pytest_bdd_after_step(self, request, feature, scenario, step, step_func, step_func_args):
Expand Down
14 changes: 5 additions & 9 deletions allure-pytest-bdd/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@
from allure_commons.utils import format_exception


def get_step_name(node, step):
name = f"{step.keyword} {step.name}"
if hasattr(node, 'callspec'):
params = node.callspec.params
for key in params:
name = name.replace(f"<{key}>", f"<{{{key}}}>")
name = name.format(**params)
return name
def get_step_name(step):
return f"{step.keyword} {step.name}"


def get_name(node, scenario):
Expand Down Expand Up @@ -50,5 +44,7 @@ def get_pytest_report_status(pytest_report):

def get_params(node):
if hasattr(node, 'callspec'):
params = node.callspec.params
params = dict(node.callspec.params)
outline_params = params.pop('_pytest_bdd_example', {})
params.update(outline_params)
return [Parameter(name=name, value=value) for name, value in params.items()]
2 changes: 0 additions & 2 deletions allure-pytest-bdd/test/outline_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from pytest_bdd import scenario
import pytest


@pytest.mark.skip(reason="https://github.com/pytest-dev/pytest-bdd/issues/447")
@scenario("../features/outline.feature", "Scenario outline")
def test_scenario_outline():
pass