(pytester)
| 4 | |
| 5 | |
| 6 | def test_steps_with_docstrings(pytester): |
| 7 | pytester.makefile( |
| 8 | ".feature", |
| 9 | docstring=textwrap.dedent( |
| 10 | ''' |
| 11 | Feature: Docstring |
| 12 | |
| 13 | Scenario: Step with plain docstring as multiline step |
| 14 | Given a step has a docstring |
| 15 | """ |
| 16 | This is a given docstring |
| 17 | """ |
| 18 | |
| 19 | When a step provides a docstring with lower indentation |
| 20 | """ |
| 21 | This is a when docstring |
| 22 | """ |
| 23 | |
| 24 | And this step has no docstring |
| 25 | |
| 26 | Then this step has a greater indentation |
| 27 | """ |
| 28 | This is a then docstring |
| 29 | """ |
| 30 | ''' |
| 31 | ), |
| 32 | ) |
| 33 | |
| 34 | pytester.makeconftest( |
| 35 | textwrap.dedent( |
| 36 | r""" |
| 37 | from pytest_bdd import given, when, then |
| 38 | from pytest_bdd.utils import dump_obj |
| 39 | |
| 40 | |
| 41 | @given("a step has a docstring") |
| 42 | def _(docstring): |
| 43 | given_docstring = docstring |
| 44 | dump_obj(given_docstring) |
| 45 | |
| 46 | |
| 47 | @when("a step provides a docstring with lower indentation") |
| 48 | def _(docstring): |
| 49 | when_docstring = docstring |
| 50 | dump_obj(when_docstring) |
| 51 | |
| 52 | |
| 53 | @when("this step has no docstring") |
| 54 | def _(): |
| 55 | pass |
| 56 | |
| 57 | |
| 58 | @then("this step has a greater indentation") |
| 59 | def _(docstring): |
| 60 | then_docstring = docstring |
| 61 | dump_obj(then_docstring) |
| 62 | """ |
| 63 | ) |
nothing calls this directly
no test coverage detected
searching dependent graphs…