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
|
@issue
@not_reproducible
Feature: Issue #231: Display the output of the last print command
. The output of the last print command in a step is not displayed
. in the behave output (at least with standard pretty formatter),
. unless the string to print ends with newline ('\n').
.
. ANALYSIS: NOT-REPRODUCIBLE
. Checked print function and stdout without newline.
. Both show the expected capture stdout output when the step fails.
@setup
Scenario: Feature Setup
Given a new working directory
And a file named "features/syndrome1.feature" with:
"""
Feature:
Scenario: Alice
Given a step passes
When a step passes
Then I write "ALICE was HERE" without newline to stdout and fail
"""
And a file named "features/syndrome2.feature" with:
"""
Feature:
Scenario: Bob
Given a step passes
Then I print "BOB was HERE" without newline and fail
"""
And a file named "features/steps/steps.py" with:
"""
from __future__ import print_function
from behave import step
import sys
@step('{word:w} step passes')
def step_passes(context, word):
pass
@step('I write "{message}" without newline to stdout and fail')
def step_write_without_newline_and_fail(context, message):
sys.stdout.write(message)
assert False, "FAIL: "+ message
@step('I print "{message}" without newline and fail')
def step_print_without_newline_and_fail(context, message):
print(message, end="")
assert False, "FAIL: "+ message
"""
Scenario: Write to stdout without newline
When I run "behave -f pretty -c -T features/syndrome1.feature"
Then it should fail with:
"""
0 scenarios passed, 1 failed, 0 skipped
2 steps passed, 1 failed, 0 skipped, 0 undefined
"""
And the command output should contain:
"""
Captured stdout:
ALICE was HERE
"""
Scenario: Use print function without newline
When I run "behave -f pretty -c -T features/syndrome2.feature"
Then it should fail with:
"""
0 scenarios passed, 1 failed, 0 skipped
1 step passed, 1 failed, 0 skipped, 0 undefined
"""
And the command output should contain:
"""
Captured stdout:
BOB was HERE
"""
|