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 78 79 80
|
@issue
Feature: Issue #66: context.text and context.table are not cleared
I noticed that context.table and context.text survive after the step is finished.
Background: Test Setup
Given a new working directory
And a file named "features/steps/steps.py" with:
"""
from behave import given, when, then
from hamcrest import assert_that, equal_to, is_not, is_, none
import six
@given(u'a step with multiline text')
def step(context):
assert context.text is not None
assert context.text, "Ensure non-empty"
assert isinstance(context.text, six.string_types)
@given(u'a step with a table')
def step(context):
assert context.table is not None
@when(u'I check the "context.{name}" attribute')
def step(context, name):
context.name = name
context.value = getattr(context, name, None)
@then(u'its value is None')
def step(context):
assert_that(context.value, is_(none()))
@then(u'its value is "{value}"')
def step(context, value):
assert_that(context.value, equal_to(value))
@then(u'its value is not "{value}"')
def step(context, value):
assert_that(value, is_not(equal_to(context.value)))
"""
Scenario: Ensure multiline text data is cleared for next step
Given a file named "features/issue66_case1.feature" with:
"""
Feature:
Scenario:
Given a step with multiline text:
'''
Alice, Bob and Charly
'''
When I check the "context.text" attribute
Then its value is not "Alice, Bob and Charly"
But its value is None
"""
When I run "behave -f plain features/issue66_case1.feature"
Then it should pass with:
"""
1 scenario passed, 0 failed, 0 skipped
4 steps passed, 0 failed, 0 skipped, 0 undefined
"""
Scenario: Ensure table data is cleared for next step
Given a file named "features/issue66_case2.feature" with:
"""
Feature:
Scenario:
Given a step with a table:
| name | gender |
| Alice | female |
| Bob | male |
When I check the "context.table" attribute
Then its value is None
"""
When I run "behave -f plain features/issue66_case2.feature"
Then it should pass with:
"""
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined
"""
|