File: test_wrong.py

package info (click to toggle)
pytest-bdd 7.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 540 kB
  • sloc: python: 3,535; makefile: 134
file content (53 lines) | stat: -rw-r--r-- 1,421 bytes parent folder | download
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
"""Test wrong feature syntax."""

import textwrap


def test_multiple_features_single_file(pytester):
    """Test validation error when multiple features are placed in a single file."""
    pytester.makefile(
        ".feature",
        wrong=textwrap.dedent(
            """\
            Feature: Feature One

              Background:
                Given I have A
                And I have B

              Scenario: Do something with A
                When I do something with A
                Then something about B

            Feature: Feature Two

              Background:
                Given I have A

              Scenario: Something that just needs A
                When I do something else with A
                Then something else about B

              Scenario: Something that needs B again
                Given I have B
                When I do something else with B
                Then something else about A and B
        """
        ),
    )
    pytester.makepyfile(
        textwrap.dedent(
            """\
        import pytest
        from pytest_bdd import then, scenario

        @scenario("wrong.feature", "Do something with A")
        def test_wrong():
            pass

        """
        )
    )
    result = pytester.runpytest()
    result.assert_outcomes(errors=1)
    result.stdout.fnmatch_lines("*FeatureError: Multiple features are not allowed in a single feature file.*")