I'm using Flask and behave
, following the instructions here.
I'm accessing pages using the Flask test client (rather than through a browser via something like Selenium). For example, calling get
on the test client to get a response.
I'd like to access Flask session data in my steps. There are various techniques documented on the Testing Flask Applications page about accessing context and sessions, but I can't see that any of them are quite what I need when using behave, in particular as I'll be accessing the page in one step and then wanting to retrieve session in another.
My environment.py
looks like this:
from my_app import app
def before_scenario(context, scenario):
app.testing = True
# load the test config to ensure e.g. right database used
app.config.from_object('parameters.test')
context.client = app.test_client()
def after_scenario(context, scenario):
pass