Skip to content

Commit fab1d7e

Browse files
committed
Add test that forward slashes (in URLs for example) in scenario outline examples are handled properly by the parser
1 parent 0d42885 commit fab1d7e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/feature/test_outline.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,50 @@ def _(string):
219219
r"bork \\",
220220
r"bork \\|",
221221
]
222+
223+
224+
def test_forward_slash_in_params(pytester):
225+
"""Test parametrized scenario when the parameter contains a slash, such in a URL."""
226+
227+
pytester.makefile(
228+
".feature",
229+
outline=textwrap.dedent(
230+
"""\
231+
Feature: Outline
232+
Scenario Outline: Outlined with slashes
233+
Given I am in <Country>
234+
Then I visit <Site>
235+
236+
Examples:
237+
| Country | Site |
238+
| US | https://my-site.com |
239+
240+
"""
241+
),
242+
)
243+
pytester.makeconftest(textwrap.dedent(STEPS))
244+
245+
pytester.makepyfile(
246+
textwrap.dedent(
247+
"""\
248+
from pytest_bdd import given, parsers, scenarios, then
249+
from pytest_bdd.utils import dump_obj
250+
251+
scenarios('outline.feature')
252+
253+
254+
@given(parsers.parse("I am in {country}"))
255+
def _(country):
256+
pass
257+
258+
259+
@then(parsers.parse("I visit {site}"))
260+
def _(site):
261+
dump_obj(site)
262+
263+
"""
264+
)
265+
)
266+
result = pytester.runpytest("-s")
267+
result.assert_outcomes(passed=1)
268+
assert collect_dumped_objects(result) == ["https://my-site.com"]

0 commit comments

Comments
 (0)