Skip to content

Commit 7e3d6dc

Browse files
committed
Remove Multiline strings
Tidy up readme example
1 parent 2d5d598 commit 7e3d6dc

File tree

2 files changed

+5
-50
lines changed

2 files changed

+5
-50
lines changed

CHANGES.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ Unreleased
66
- Update documentation to clarify that `--gherkin-terminal-reporter` needs to be used with `-v` or `-vv`.
77
- Drop compatibility with pytest < 7.0.0.
88
- Continuation of steps using asterisks instead of And/But supported.
9-
- Added `datatable` argument for steps that contain a datatable (see Data Tables section at https://cucumber.io/docs/gherkin/reference/)
10-
- Added `docstring` argument for steps that contain a docstring (see Doc Strings section at https://cucumber.io/docs/gherkin/reference/).
9+
- Added `datatable` argument for steps that contain a datatable (see `Data Tables <https://cucumber.io/docs/gherkin/reference/#data-tables>`).
10+
- Added `docstring` argument for steps that contain a docstring (see `Doc Strings <https://cucumber.io/docs/gherkin/reference/#doc-strings>`).
11+
- Multiline strings no longer match name based on multiple lines - only on the actual step text on the step line.
1112

1213
8.0.0b1
1314
----------

README.rst

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -428,53 +428,6 @@ A common use case is when we have to assert the outcome of an HTTP request:
428428
Then the request should be successful
429429
430430
431-
Multiline steps
432-
---------------
433-
434-
As Gherkin, pytest-bdd supports multiline steps
435-
(a.k.a. `Doc Strings <https://cucumber.io/docs/gherkin/reference/#doc-strings>`_).
436-
437-
.. code-block:: gherkin
438-
439-
Feature: Multiline steps
440-
Scenario: Multiline step using sub indentation
441-
Given I have a step with:
442-
"""
443-
Some
444-
Extra
445-
Lines
446-
"""
447-
Then the text should be parsed with correct indentation
448-
449-
A step is considered as a multiline one, if the **next** line(s) after its first line is encapsulated by
450-
triple quotes. The step name is then simply extended by adding further lines inside the triple quotes.
451-
In the example above, the Given step name will be:
452-
453-
.. code-block:: python
454-
455-
'I have a step with:\nSome\nExtra\nLines'
456-
457-
You can of course register a step using the full name (including the newlines), but it seems more practical to use
458-
step arguments and capture lines after first line (or some subset of them) into the argument:
459-
460-
.. code-block:: python
461-
462-
from pytest_bdd import given, then, scenario, parsers
463-
464-
465-
scenarios("multiline.feature")
466-
467-
468-
@given(parsers.parse("I have a step with:\n{content}"), target_fixture="text")
469-
def given_text(content):
470-
return content
471-
472-
473-
@then("the text should be parsed with correct indentation")
474-
def text_should_be_correct(text):
475-
assert text == "Some\nExtra\nLines"
476-
477-
478431
Scenarios shortcut
479432
------------------
480433

@@ -685,6 +638,7 @@ Full example:
685638
Given a step has a docstring
686639
"""
687640
This is a given docstring
641+
on two lines
688642
"""
689643
690644
When a step provides a docstring with lower indentation
@@ -707,7 +661,7 @@ Full example:
707661
708662
@given("a step has a docstring")
709663
def _(docstring):
710-
print(docstring)
664+
assert docstring == "This is a given docstring\non two lines"
711665
712666
@when("a step provides a docstring with lower indentation")
713667
def _(docstring):

0 commit comments

Comments
 (0)