Skip to content

Commit

Permalink
Merge pull request #195 from The-Compiler/at
Browse files Browse the repository at this point in the history
Don't parse scenario lines containing @ as tag
  • Loading branch information
olegpidsadnyi committed Sep 19, 2016
2 parents e0761dd + 14cc037 commit 6cd65b6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

2.17.2
------

- Fix scenairo lines containing an ``@`` being parsed as a tag. (The-Compiler)

2.17.1
------

Expand Down
2 changes: 1 addition & 1 deletion pytest_bdd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
from pytest_bdd.steps import given, when, then
from pytest_bdd.scenario import scenario, scenarios

__version__ = '2.17.1'
__version__ = '2.17.2'

__all__ = [given.__name__, when.__name__, then.__name__, scenario.__name__, scenarios.__name__]
2 changes: 1 addition & 1 deletion pytest_bdd/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get_tags(line):
:return: List of tags.
"""
if not line or '@' not in line.strip():
if not line or not line.strip().startswith('@'):
return set()
return (
set((tag.lstrip('@') for tag in line.strip().split(' @') if len(tag) > 1))
Expand Down
31 changes: 31 additions & 0 deletions tests/feature/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,37 @@ def i_have_bar():
)


def test_at_in_scenario(testdir):
testdir.makefile('.feature', test="""
Feature: At sign in a scenario
Scenario: Tags
Given I have a foo@bar
Scenario: Second
Given I have a baz
""")
testdir.makepyfile("""
from pytest_bdd import given, scenarios
@given('I have a foo@bar')
def i_have_at():
return 'foo@bar'
@given('I have a baz')
def i_have_baz():
return 'baz'
scenarios('test.feature')
""")
result = testdir.runpytest_subprocess('--strict')
result.stdout.fnmatch_lines(
[
"*= 2 passed * =*",
],
)


@pytest.mark.parametrize('line, expected', [
('@foo @bar', {'foo', 'bar'}),
('@with spaces @bar', {'with spaces', 'bar'}),
Expand Down

0 comments on commit 6cd65b6

Please sign in to comment.