1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
"""Test descriptions."""
import textwrap
def test_description(pytester):
"""Test description for the feature."""
pytester.makefile(
".feature",
description=textwrap.dedent(
"""\
Feature: Description
In order to achieve something
I want something
Because it will be cool
Some description goes here.
Scenario: Description
Also, the scenario can have a description.
It goes here between the scenario name
and the first step.
Given I have a bar
"""
),
)
pytester.makepyfile(
textwrap.dedent(
"""\
import textwrap
from pytest_bdd import given, scenario
@scenario("description.feature", "Description")
def test_description():
pass
@given("I have a bar")
def _():
return "bar"
def test_feature_description():
assert test_description.__scenario__.feature.description == textwrap.dedent(
\"\"\"\\
In order to achieve something
I want something
Because it will be cool
Some description goes here.\"\"\"
)
def test_scenario_description():
assert test_description.__scenario__.description == textwrap.dedent(
\"\"\"\\
Also, the scenario can have a description.
It goes here between the scenario name
and the first step.\"\"\"
)
"""
)
)
result = pytester.runpytest()
result.assert_outcomes(passed=3)
|