| 1 |
@issue |
| 2 |
Feature: Issue #288 -- Use print function instead print statement in environment/steps files |
| 3 |
|
| 4 |
. Loaded files have future flags of importing module "behave.runner". |
| 5 |
. This should be removed. |
| 6 |
. |
| 7 |
. AFFECTED FILES: |
| 8 |
. * features/environment.py |
| 9 |
. * features/steps/*.py |
| 10 |
. |
| 11 |
. AFFECTED FUTURE FLAGS: |
| 12 |
. * print_function |
| 13 |
. * absolute_import |
| 14 |
. * ... |
| 15 |
|
| 16 |
@setup |
| 17 |
Scenario: Feature Setup |
| 18 |
Given a new working directory |
| 19 |
And a file named "features/steps/reuse_steps.py" with: |
| 20 |
""" |
| 21 |
from behave4cmd0 import passing_steps |
| 22 |
""" |
| 23 |
And a file named "features/passing.feature" with: |
| 24 |
""" |
| 25 |
Feature: |
| 26 |
Scenario: |
| 27 |
Given a step passes |
| 28 |
""" |
| 29 |
|
| 30 |
@preferred |
| 31 |
Scenario: Use print function with future-statement in steps/environment (PY2, PY3) |
| 32 |
Given a file named "features/steps/my_steps.py" with: |
| 33 |
""" |
| 34 |
from __future__ import print_function |
| 35 |
print("Hello step") |
| 36 |
""" |
| 37 |
And a file named "features/environment.py" with: |
| 38 |
""" |
| 39 |
from __future__ import print_function |
| 40 |
print("Hello environment") |
| 41 |
""" |
| 42 |
When I run "behave -f plain features/passing.feature" |
| 43 |
Then it should pass with: |
| 44 |
""" |
| 45 |
1 scenario passed, 0 failed, 0 skipped |
| 46 |
1 step passed, 0 failed, 0 skipped, 0 undefined |
| 47 |
""" |
| 48 |
And the command output should not contain: |
| 49 |
""" |
| 50 |
Traceback (most recent call last): |
| 51 |
""" |
| 52 |
|
| 53 |
@use.with_python2=true |
| 54 |
Scenario: Use python2 print keyword in steps/environment |
| 55 |
Given a file named "features/steps/my_steps.py" with: |
| 56 |
""" |
| 57 |
print "Hello step" |
| 58 |
""" |
| 59 |
And a file named "features/environment.py" with: |
| 60 |
""" |
| 61 |
print "Hello step" |
| 62 |
""" |
| 63 |
When I run "behave -f plain features/passing.feature" |
| 64 |
Then it should pass with: |
| 65 |
""" |
| 66 |
1 scenario passed, 0 failed, 0 skipped |
| 67 |
1 step passed, 0 failed, 0 skipped, 0 undefined |
| 68 |
""" |
| 69 |
And the command output should not contain "SyntaxError" |
| 70 |
And the command output should not contain: |
| 71 |
""" |
| 72 |
Traceback (most recent call last): |
| 73 |
""" |
| 74 |
|
| 75 |
@use.with_python3=true |
| 76 |
Scenario: Use print function without future-statement in steps/environment (PY3) |
| 77 |
Given a file named "features/steps/my_steps.py" with: |
| 78 |
""" |
| 79 |
print("Hello step") |
| 80 |
""" |
| 81 |
And a file named "features/environment.py" with: |
| 82 |
""" |
| 83 |
print("Hello environment") |
| 84 |
""" |
| 85 |
When I run "behave -f plain features/passing.feature" |
| 86 |
Then it should pass with: |
| 87 |
""" |
| 88 |
1 scenario passed, 0 failed, 0 skipped |
| 89 |
1 step passed, 0 failed, 0 skipped, 0 undefined |
| 90 |
""" |
| 91 |
And the command output should not contain: |
| 92 |
""" |
| 93 |
Traceback (most recent call last): |
| 94 |
""" |
| 95 |
|