Test description for the feature.
(pytester)
| 4 | |
| 5 | |
| 6 | def test_description(pytester): |
| 7 | """Test description for the feature.""" |
| 8 | pytester.makefile( |
| 9 | ".feature", |
| 10 | description=textwrap.dedent( |
| 11 | """\ |
| 12 | Feature: Description |
| 13 | |
| 14 | In order to achieve something |
| 15 | I want something |
| 16 | Because it will be cool |
| 17 | |
| 18 | |
| 19 | Some description goes here. |
| 20 | |
| 21 | Scenario: Description |
| 22 | Also, the scenario can have a description. |
| 23 | |
| 24 | It goes here between the scenario name |
| 25 | and the first step. |
| 26 | Given I have a bar |
| 27 | """ |
| 28 | ), |
| 29 | ) |
| 30 | |
| 31 | pytester.makepyfile( |
| 32 | textwrap.dedent( |
| 33 | r''' |
| 34 | import textwrap |
| 35 | from pytest_bdd import given, scenario |
| 36 | |
| 37 | @scenario("description.feature", "Description") |
| 38 | def test_description(): |
| 39 | pass |
| 40 | |
| 41 | |
| 42 | @given("I have a bar") |
| 43 | def _(): |
| 44 | return "bar" |
| 45 | |
| 46 | def test_feature_description(): |
| 47 | assert test_description.__scenario__.feature.description == textwrap.dedent( |
| 48 | "In order to achieve something\nI want something\nBecause it will be cool\n\n\nSome description goes here." |
| 49 | ) |
| 50 | |
| 51 | def test_scenario_description(): |
| 52 | assert test_description.__scenario__.description == textwrap.dedent( |
| 53 | "Also, the scenario can have a description.\n\nIt goes here between the scenario name\nand the first step.""" |
| 54 | ) |
| 55 | ''' |
| 56 | ) |
| 57 | ) |
| 58 | |
| 59 | result = pytester.runpytest() |
| 60 | result.assert_outcomes(passed=3) |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…