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

Test for keywords outside step handled correctly #710

Merged
merged 1 commit into from
Sep 28, 2024
Merged
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
39 changes: 39 additions & 0 deletions tests/feature/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,3 +653,42 @@ def _():
)
result = pytester.runpytest()
result.assert_outcomes(passed=1, failed=0)


def test_keywords_used_outside_steps(pytester):
"""Correctly identify when keyword is used for steps and when it's used for other cases."""
pytester.makefile(
".feature",
keywords="""\
Feature: Given this is a Description

In order to achieve something
I want something
Because it will be cool
Given it is valid description
When it starts working
Then I will be happy


Some description goes here.

Scenario: When I set a Description
Given I have a bar
""",
)
pytester.makepyfile(
textwrap.dedent(
"""\
from pytest_bdd import given, scenarios

scenarios("keywords.feature")

@given("I have a bar")
def _():
pass

"""
)
)
result = pytester.runpytest()
result.assert_outcomes(passed=1, failed=0)
Loading