File: issue0424.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 (66 lines) | stat: -rw-r--r-- 2,236 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
@issue
@unicode
Feature: Issue #424 -- Unicode output problem when fails in nested steps

    . HINTS:
    .   * Python step file should have encoding line (# -*- coding: ... -*-)
    .   * Assert failure message should use unicode-string instead of byte-string

    Scenario:
      Given a new working directory
      And a file named "features/steps/pass_steps.py" with:
        """
        from behave import step

        @step('{word:w} step passes')
        def step_passes(context, word):
            pass
        """
      And a file named "features/steps/steps.py" with:
        """
        # -*- coding: UTF-8 -*-
        # NOTE: Python2 requires encoding to decode special chars correctly.
        from behave import step

        @step('I press the big red button')
        def step_press_red_button(context):
            assert False, u"Ungültiger Wert"  # HINT: Special chars require Unicode.

        @step('I call the nested step with the "red button"')
        def step_press_red_button(context):
            context.execute_steps(u'When I press the big red button')
        """
      And a file named "behave.ini" with:
          """
          [behave]
          show_timings = false
          """
      And a file named "features/alice.feature" with:
        """
        Feature:

          Scenario: Use step directly
            When I press the big red button

          Scenario: Use nested step
            Given another step passes
            When I call the nested step with the "red button"
        """
      When I run "behave -f plain features/alice.feature"
      Then it should fail with:
        """
        0 scenarios passed, 2 failed, 0 skipped
        1 step passed, 2 failed, 0 skipped, 0 undefined
        """
      And the command output should contain:
        """
        Scenario: Use step directly
          When I press the big red button ... failed
        Assertion Failed: Ungültiger Wert

        Scenario: Use nested step
          Given another step passes ... passed
          When I call the nested step with the "red button" ... failed
        Assertion Failed: FAILED SUB-STEP: When I press the big red button
        Substep info: Assertion Failed: Ungültiger Wert
        """