(pytester)
| 81 | |
| 82 | |
| 83 | def test_steps_with_missing_docstring(pytester): |
| 84 | pytester.makefile( |
| 85 | ".feature", |
| 86 | missing_docstring=textwrap.dedent( |
| 87 | '''\ |
| 88 | Feature: Missing docstring |
| 89 | |
| 90 | Scenario: Docstring is missing for a step |
| 91 | Given this step has a docstring |
| 92 | """ |
| 93 | This is a given docstring |
| 94 | """ |
| 95 | |
| 96 | When this step has no docstring but tries to use the docstring argument |
| 97 | Then an error is thrown |
| 98 | ''' |
| 99 | ), |
| 100 | ) |
| 101 | pytester.makeconftest( |
| 102 | textwrap.dedent( |
| 103 | """\ |
| 104 | from pytest_bdd import given, when, then |
| 105 | |
| 106 | |
| 107 | @given("this step has a docstring") |
| 108 | def _(docstring): |
| 109 | print(docstring) |
| 110 | |
| 111 | |
| 112 | @when("this step has no docstring but tries to use the docstring argument") |
| 113 | def _(docstring): |
| 114 | print(docstring) |
| 115 | |
| 116 | |
| 117 | @then("an error is thrown") |
| 118 | def _(): |
| 119 | pass |
| 120 | |
| 121 | """ |
| 122 | ) |
| 123 | ) |
| 124 | |
| 125 | pytester.makepyfile( |
| 126 | textwrap.dedent( |
| 127 | """\ |
| 128 | from pytest_bdd import scenarios |
| 129 | |
| 130 | scenarios("missing_docstring.feature") |
| 131 | """ |
| 132 | ) |
| 133 | ) |
| 134 | result = pytester.runpytest("-s") |
| 135 | result.assert_outcomes(failed=1) |
| 136 | result.stdout.fnmatch_lines(["*fixture 'docstring' not found*"]) |
| 137 | |
| 138 | |
| 139 | def test_docstring_argument_in_step_impl_is_optional(pytester): |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…