| 1 |
@issue |
| 2 |
Feature: Issue #83: behave.__main__:main() Various sys.exit issues |
| 3 |
|
| 4 |
. Currently, the main function has several issues related |
| 5 |
. to sys.exit() returncode usage: |
| 6 |
. |
| 7 |
. 1. sys.exit("string") is invalid, a number must be used: |
| 8 |
. => Used in exception cases after run (ParseError, ConfigError) |
| 9 |
. |
| 10 |
. 2. On success, the main() function returns implicitly None |
| 11 |
. instead of using sys.exit(0) |
| 12 |
. => No statement at end of function after failed case. |
| 13 |
|
| 14 |
@setup |
| 15 |
Scenario: Feature Setup |
| 16 |
Given a new working directory |
| 17 |
And a file named "features/steps/steps.py" with: |
| 18 |
""" |
| 19 |
from behave import step |
| 20 |
|
| 21 |
@step(u'a step passes') |
| 22 |
def step_passes(context): |
| 23 |
pass |
| 24 |
""" |
| 25 |
|
| 26 |
Scenario: Successful test run |
| 27 |
Given a file named "features/passing.feature" with: |
| 28 |
""" |
| 29 |
Feature: |
| 30 |
Scenario: |
| 31 |
Given a step passes |
| 32 |
When a step passes |
| 33 |
Then a step passes |
| 34 |
""" |
| 35 |
When I run "behave -c features/passing.feature" |
| 36 |
Then it should pass |
| 37 |
And the command returncode is "0" |
| 38 |
|
| 39 |
Scenario: ParseError occurs |
| 40 |
Given a file named "features/invalid_with_ParseError.feature" with: |
| 41 |
""" |
| 42 |
Feature: |
| 43 |
Scenario: Invalid scenario which raises ParseError |
| 44 |
Given a step passes |
| 45 |
When2 a step passes |
| 46 |
""" |
| 47 |
When I run "behave -c features/invalid_with_ParseError.feature" |
| 48 |
Then it should fail |
| 49 |
And the command returncode is non-zero |
| 50 |
And the command output should contain: |
| 51 |
""" |
| 52 |
Failed to parse "{__WORKDIR__}/features/invalid_with_ParseError.feature" |
| 53 |
""" |
| 54 |
|
| 55 |
Scenario: ConfigError occurs |
| 56 |
Given a new working directory |
| 57 |
And a file named "features/passing2.feature" with: |
| 58 |
""" |
| 59 |
Feature: |
| 60 |
Scenario: |
| 61 |
Given a step passes |
| 62 |
""" |
| 63 |
When I run "behave -c features/passing2.feature" |
| 64 |
Then it should fail |
| 65 |
And the command returncode is non-zero |
| 66 |
And the command output should contain: |
| 67 |
""" |
| 68 |
No steps directory in '{__WORKDIR__}/features' |
| 69 |
""" |