I'm trying to use behave, in python, to make runnable steps for a feature file. I'm using the 'context' default arg into steps for passing values and objects. But behave tells me "AttributeError: 'Context' object has no attribute <the var name I putted before>'"
I'm sharing with you the current code:
from autorg.application.input import AppInput
from tests.helpers.repository import InMemoryRepository
"""Step implementation for cli"""
def get_repo_with_inputs():
repo = InMemoryRepository()
inputs = ["hello1","how2","are3","you4"]
for input in inputs:
repo.store(input)
return repo
@given(u'que la bandeja de entrada contiene inputs')
def step_impl(context):
repo = get_repo_with_inputs()
context.ut = AppInput(repo)
@when(u'el usuario indique al sistema que desea ver una lista de inputs en la bandeja de entrada')
def step_impl(context):
inputs = context.ut.list_inputs()
@then(u'el sistma deberia mostrarle una lista de inputs actuales que contiene la bandeja de entrada')
def step_impl(context):
pass
And terminal says...
Escenario: el usuario lista los inputs recopilados en la bandeja pero no hay inputs # docs/features/cli.feature:10
Dado que la bandeja de entrada no contiene inputs # docs/features/steps/cli.py:29 0.000s
Cuando el usuario indique al sistema que desea ver una lista de inputs en la bandeja de entrada # docs/features/steps/cli.py:20 0.000s
Traceback (most recent call last):
File "/home/peace/.cache/pypoetry/virtualenvs/autorg-from-ddd-EEXSK3FH-py3.11/lib/python3.11/site-packages/behave/model.py", line 1329, in run
match.run(runner.context)
File "/home/peace/.cache/pypoetry/virtualenvs/autorg-from-ddd-EEXSK3FH-py3.11/lib/python3.11/site-packages/behave/matchers.py", line 98, in run
self.func(context, *args, **kwargs)
File "docs/features/steps/cli.py", line 22, in step_impl
inputs = context.ut.list_inputs()
^^^^^^^^^^
File "/home/peace/.cache/pypoetry/virtualenvs/autorg-from-ddd-EEXSK3FH-py3.11/lib/python3.11/site-packages/behave/runner.py", line 321, in __getattr__
raise AttributeError(msg)
AttributeError: 'Context' object has no attribute 'ut'
Note: I'm executing behave in a different path that the standard "project/features/...", i'm using project_folder/docs/features/cli.feature. I dont believe this has something to do anyway.
¿Can you to gide me on what's going on here?
Hi. I'm trying to use behave, in python, to make runnable steps for a feature file. I'm using the 'context' default arg into steps for passing values and objects. But behave tells me "AttributeError: 'Context' object has no attribute <the var name I putted before>'"
I'm sharing with you the current code:
from autorg.application.input import AppInput
from tests.helpers.repository import InMemoryRepository
"""Step implementation for cli"""
def get_repo_with_inputs():
repo = InMemoryRepository()
inputs = ["hello1","how2","are3","you4"]
for input in inputs:
repo.store(input)
return repo
@given(u'que la bandeja de entrada contiene inputs')
def step_impl(context):
repo = get_repo_with_inputs()
context.ut = AppInput(repo)
@when(u'el usuario indique al sistema que desea ver una lista de inputs en la bandeja de entrada')
def step_impl(context):
inputs = context.ut.list_inputs()
@then(u'el sistma deberia mostrarle una lista de inputs actuales que contiene la bandeja de entrada')
def step_impl(context):
pass
And terminal says...
Escenario: el usuario lista los inputs recopilados en la bandeja pero no hay inputs # docs/features/cli.feature:10
Dado que la bandeja de entrada no contiene inputs # docs/features/steps/cli.py:29 0.000s
Cuando el usuario indique al sistema que desea ver una lista de inputs en la bandeja de entrada # docs/features/steps/cli.py:20 0.000s
Traceback (most recent call last):
File "/home/peace/.cache/pypoetry/virtualenvs/autorg-from-ddd-EEXSK3FH-py3.11/lib/python3.11/site-packages/behave/model.py", line 1329, in run
match.run(runner.context)
File "/home/peace/.cache/pypoetry/virtualenvs/autorg-from-ddd-EEXSK3FH-py3.11/lib/python3.11/site-packages/behave/matchers.py", line 98, in run
self.func(context, *args, **kwargs)
File "docs/features/steps/cli.py", line 22, in step_impl
inputs = context.ut.list_inputs()
^^^^^^^^^^
File "/home/peace/.cache/pypoetry/virtualenvs/autorg-from-ddd-EEXSK3FH-py3.11/lib/python3.11/site-packages/behave/runner.py", line 321, in __getattr__
raise AttributeError(msg)
AttributeError: 'Context' object has no attribute 'ut'
Note: I'm executing behave in a different path that the standard "project/features/...", i'm using project_folder/docs/features/cli.feature. I dont believe this has something to do anyway.
¿Can you to gide me on what's going on here?