diff --git a/allure-pytest-bdd/features/outline.feature b/allure-pytest-bdd/features/outline.feature index 2cb37e03..5058739d 100644 --- a/allure-pytest-bdd/features/outline.feature +++ b/allure-pytest-bdd/features/outline.feature @@ -16,9 +16,9 @@ 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(" step") + @given(parsers.parse("{first} step")) def given_step(first): pass @@ -26,7 +26,7 @@ Feature: Scenario outline def nope_step(): pass - @then("step with param") + @then(parsers.parse("step with {second} param")) def then_step(second): pass @@ -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 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 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 diff --git a/allure-pytest-bdd/src/pytest_bdd_listener.py b/allure-pytest-bdd/src/pytest_bdd_listener.py index 8c02ef08..9a4f5fac 100644 --- a/allure-pytest-bdd/src/pytest_bdd_listener.py +++ b/allure-pytest-bdd/src/pytest_bdd_listener.py @@ -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): diff --git a/allure-pytest-bdd/src/utils.py b/allure-pytest-bdd/src/utils.py index e21f234a..ac70aac2 100644 --- a/allure-pytest-bdd/src/utils.py +++ b/allure-pytest-bdd/src/utils.py @@ -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): @@ -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()] diff --git a/allure-pytest-bdd/test/outline_test.py b/allure-pytest-bdd/test/outline_test.py index fddfd11d..d176148a 100644 --- a/allure-pytest-bdd/test/outline_test.py +++ b/allure-pytest-bdd/test/outline_test.py @@ -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