| 1 |
@issue |
| 2 |
Feature: Issue #597 -- Steps with accented letters doesn't seem to work |
| 3 |
|
| 4 |
|
| 5 |
Background: |
| 6 |
Given a new working directory |
| 7 |
And a file named "features/french.feature" with: |
| 8 |
""" |
| 9 |
# language: fr |
| 10 |
Fonctionnalité: Alice |
| 11 |
|
| 12 |
Scénario: A1 |
| 13 |
Soit allé |
| 14 |
Quand comment |
| 15 |
Alors cava |
| 16 |
""" |
| 17 |
And a file named "behave.ini" with: |
| 18 |
""" |
| 19 |
[behave] |
| 20 |
show_timings = false |
| 21 |
""" |
| 22 |
|
| 23 |
Scenario: Passing w/o Encoding-Hint in Steps File (case: py2, py3) |
| 24 |
Given a file named "features/steps/french_steps.py" with: |
| 25 |
""" |
| 26 |
# -*- coding: UTF-8 -*- |
| 27 |
from behave import given, when, then |
| 28 |
|
| 29 |
@given(u'allé') |
| 30 |
def given_step_alle(ctx): |
| 31 |
pass |
| 32 |
|
| 33 |
@when(u'comment') |
| 34 |
def when_step_comment(ctx): |
| 35 |
pass |
| 36 |
|
| 37 |
@then(u'cava') |
| 38 |
def then_step_cava(ctx): |
| 39 |
pass |
| 40 |
""" |
| 41 |
When I run "behave -f plain features/" |
| 42 |
Then it should pass with: |
| 43 |
""" |
| 44 |
Fonctionnalité: Alice |
| 45 |
|
| 46 |
Scénario: A1 |
| 47 |
Soit allé ... passed |
| 48 |
Quand comment ... passed |
| 49 |
Alors cava ... passed |
| 50 |
|
| 51 |
1 feature passed, 0 failed, 0 skipped |
| 52 |
1 scenario passed, 0 failed, 0 skipped |
| 53 |
3 steps passed, 0 failed, 0 skipped, 0 undefined |
| 54 |
""" |
| 55 |
|
| 56 |
@only.with_python2=true |
| 57 |
Scenario: Failing w/o Encoding-Hint in Steps File (case: python2) |
| 58 |
Given a file named "features/steps/french_steps.py" with: |
| 59 |
""" |
| 60 |
from behave import given, when, then |
| 61 |
|
| 62 |
@given(u'allé') |
| 63 |
def given_step_alle(ctx): |
| 64 |
pass |
| 65 |
|
| 66 |
@when(u'comment') |
| 67 |
def when_step_comment(ctx): |
| 68 |
pass |
| 69 |
|
| 70 |
@then(u'cava') |
| 71 |
def then_step_cava(ctx): |
| 72 |
pass |
| 73 |
""" |
| 74 |
When I run "behave -f plain features/" |
| 75 |
Then it should fail with: |
| 76 |
""" |
| 77 |
0 features passed, 1 failed, 0 skipped |
| 78 |
0 scenarios passed, 1 failed, 0 skipped |
| 79 |
0 steps passed, 0 failed, 2 skipped, 1 undefined |
| 80 |
""" |
| 81 |
And the command output should contain: |
| 82 |
""" |
| 83 |
Scénario: A1 |
| 84 |
Soit allé ... undefined |
| 85 |
""" |
| 86 |
And the command output should contain: |
| 87 |
""" |
| 88 |
You can implement step definitions for undefined steps with these snippets: |
| 89 |
|
| 90 |
@given(u'allé') |
| 91 |
def step_impl(context): |
| 92 |
raise NotImplementedError(u'STEP: Given allé') |
| 93 |
""" |
| 94 |
But note that "python2 uses encoding=ascii" |
| 95 |
And note that "encoding-hint in steps file solves the problem" |
| 96 |
|
| 97 |
|
| 98 |
@not.with_python2=true |
| 99 |
Scenario: Passing w/o Encoding-Hint in Steps File (case: python3) |
| 100 |
Given a file named "features/steps/french_steps.py" with: |
| 101 |
""" |
| 102 |
from behave import given, when, then |
| 103 |
|
| 104 |
@given(u'allé') |
| 105 |
def given_step_alle(ctx): |
| 106 |
pass |
| 107 |
|
| 108 |
@when(u'comment') |
| 109 |
def when_step_comment(ctx): |
| 110 |
pass |
| 111 |
|
| 112 |
@then(u'cava') |
| 113 |
def then_step_cava(ctx): |
| 114 |
pass |
| 115 |
""" |
| 116 |
When I run "behave -f plain features/" |
| 117 |
Then it should pass with: |
| 118 |
""" |
| 119 |
1 feature passed, 0 failed, 0 skipped |
| 120 |
1 scenario passed, 0 failed, 0 skipped |
| 121 |
3 steps passed, 0 failed, 0 skipped, 0 undefined |
| 122 |
""" |
| 123 |
And the command output should contain: |
| 124 |
""" |
| 125 |
Scénario: A1 |
| 126 |
Soit allé ... passed |
| 127 |
""" |
| 128 |
And the command output should not contain: |
| 129 |
""" |
| 130 |
@given(u'allé') |
| 131 |
def step_impl(context): |
| 132 |
raise NotImplementedError(u'STEP: Given allé') |
| 133 |
""" |
| 134 |
But note that "python3 discovers encoding (or uses encoding=UTF-8)" |