File: issue0302.feature

package info (click to toggle)
behave 1.2.6-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,160 kB
  • sloc: python: 19,857; makefile: 137; sh: 18
file content (91 lines) | stat: -rw-r--r-- 2,965 bytes parent folder | download | duplicates (3)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@issue
Feature: Issue #302: Cannot escape pipe in table field value

  Support escaped-pipe characters in cells of a table.

  @setup
  Scenario: Feature Setup
    Given a new working directory
    And a file named "features/steps/steps.py" with:
        """
        from behave import then, step
        from hamcrest import assert_that, equal_to

        @step(u'I use table data with')
        def step_use_table_data_with_table(context):
            assert context.table, "REQUIRE: context.table is provided"
            context.table.require_columns(["name", "value"])

            context.table_data = {}
            for row in context.table.rows:
                name = row["name"]
                value = row["value"]
                context.table_data[name] = value

        @then(u'table data "{name}" is "{value}"')
        def step_table_data_name_is_value(context, name, value):
            table_data = context.table_data
            actual_value = table_data[name]
            assert_that(actual_value, equal_to(value))
        """

  Scenario: Escaped-pipes in table cell
    Given a file named "features/issue0302_example.feature" with:
        """
        Feature:
            Scenario: Use a table
             Given I use table data with:
                 | name  | value |
                 | alice | one\|two\|three\|four  |
             Then table data "alice" is "one|two|three|four"
        """
    When I run "behave -f plain features/issue0302_example.feature"
    Then it should pass
    And the command output should not contain:
        """
        Traceback (most recent call last):
        """


  Scenario: Leading escaped-pipe in table cell
    Given a file named "features/issue0302_example2.feature" with:
        """
        Feature:
            Scenario: Use a table
             Given I use table data with:
                 | name  | value |
                 | bob   |\|one  |
             Then table data "bob" is "|one"
        """
    When I run "behave -f plain features/issue0302_example2.feature"
    Then it should pass


  Scenario: Trailing escaped-pipe in table cell
    Given a file named "features/issue0302_example3.feature" with:
        """
        Feature:
            Scenario: Use a table
             Given I use table data with:
                 | name   | value |
                 | charly | one\||
             Then table data "charly" is "one|"
        """
    When I run "behave -f plain features/issue0302_example3.feature"
    Then it should pass


  Scenario: Double escaped-pipe in table cell
    Given a file named "features/issue0302_example4.feature" with:
        """
        Feature:
            Scenario: Use a table
             Given I use table data with:
                 | name   | value |
                 | doro   | one\\|two |
             Then table data "doro" is "one\|two"
        """
    When I run "behave -f plain features/issue0302_example4.feature"
    Then it should pass