I am not too familiar with Python, but I have a BDD structure using Python, now I want to create a world map class that stores data and is retrieved in all scripts.
For example, I will have a class in which I can use:
World w
w.key.add('key', api.response)
In one scenario and in another I can use:
World w
key = w.key.get('key').
Edit:
Or, if there is a built-in way to use context or similar in maintenance where attributes are stored and retrieved in all scenarios that would be good.
Like a salad, where you can use the world http://lettuce.it/tutorial/simple.html
I tried this between scripts but didn't seem to collect it
class World(dict):
def __setitem__(self, key, item):
self.__dict__[key] = item
print(item)
def __getitem__(self, key):
return self.__dict__[key]
A: w. setitem ( "", )
B: w. getitem ('key',)
:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-packages\behave\model.py", line 1456, in run
match.run(runner.context)
File "C:\Program Files (x86)\Python\lib\site-packages\behave\model.py", line 1903, in run
self.func(context, *args, **kwargs)
File "steps\get_account.py", line 14, in step_impl
print(w.__getitem__('appToken'))
File "C:Project\steps\world.py", line 8, in __getitem__
return self.__dict__[key]
KeyError: 'key'
, World .
:
, environment.py, , . environment.py , ?
Edit:
environment.py hardcoded, environment.py ?