Behave>>before_all context.userdata not able to access from step definition

22 views
Skip to first unread message

Bhupesh Dahal

unread,
Jun 7, 2018, 5:39:53 PM6/7/18
to Behaviour Driven Development
So under before_all i am loading yml file to context.userdata.  data is accessible in environment.py but it is not accessible when in steps file. Is the context object available outside env file ?

here's sample code 
environment.py file 

import yaml

def before_all(context):
context.userdata = yaml.load(open('./features/data/test.yml', 'r'))
    print(context.userdata['row1'])  #this works


now steps file 
@then('print the context data')
def step_impl(context):
    print(context.userdata['row1'])  #this does not do anything 

Any help ?
Reply all
Reply to author
Forward
0 new messages