@@ -428,53 +428,6 @@ A common use case is when we have to assert the outcome of an HTTP request:
428
428
Then the request should be successful
429
429
430
430
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:\n Some\n Extra\n Lines'
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\n Extra\n Lines"
476
-
477
-
478
431
Scenarios shortcut
479
432
------------------
480
433
@@ -685,6 +638,7 @@ Full example:
685
638
Given a step has a docstring
686
639
"""
687
640
This is a given docstring
641
+ on two lines
688
642
"""
689
643
690
644
When a step provides a docstring with lower indentation
@@ -707,7 +661,7 @@ Full example:
707
661
708
662
@given (" a step has a docstring" )
709
663
def _ (docstring ):
710
- print ( docstring)
664
+ assert docstring == " This is a given docstring \n on two lines "
711
665
712
666
@when (" a step provides a docstring with lower indentation" )
713
667
def _ (docstring ):
0 commit comments