Python の動作から始めて、コンテキストにアクセスしようとするとスタックしました - 利用できません。これが私のコードです:
機能ファイルは次のとおりです。
Feature: Company staff inventory
Scenario: count company staff
Given a set of employees:
| name | dept |
| Paul | IT |
| Mary | IT |
| Pete | Dev |
When we count the number of employees in each department
Then we will find two people in IT
And we will find one employee in Dev
ステップファイルは次のとおりです。
from behave import *
@given('a set of employees')
def step_impl(context):
assert context is True
@when('we count the number of employees in each department')
def step_impl(context):
context.res = dict()
for row in context.table:
for k, v in row:
if k not in context.res:
context.res[k] = 1
else:
context.res[k] += 1
@then('we will find two people in IT')
def step_impl(context):
assert context.res['IT'] == 2
@then('we will find one employee in Dev')
def step_impl(context):
assert context.res['Dev'] == 1
トレースバックは次のとおりです。
Traceback (most recent call last):
File "/home/kseniyab/Documents/broadsign_code/spikes/BDD_Gherkin/behave/src/py3behave/lib/python3.4/site-packages/behave/model.py", line 1456, in run
match.run(runner.context)
File "/home/kseniyab/Documents/broadsign_code/spikes/BDD_Gherkin/behave/src/py3behave/lib/python3.4/site-packages/behave/model.py", line 1903, in run
self.func(context, *args, **kwargs)
File "steps/count_staff.py", line 5, in step_impl
assert context is True
AssertionError