How can I access the app
variable from app.py when running pytest?
On the Dash Testing page it gives an example where functions are imported from app.py and another example where a new app
is created within the test function:
def test_001_child_with_0(dash_duo):
app = dash.Dash(__name__)
app.layout = html.Div(id="nully-wrapper", children=0)
dash_duo.start_server(app)
But how can I get the app
variable set in app.py? If I try to run it this:
from app import app
def test_001_child_with_0(dash_duo):
dash_duo.start_server(app)
....
…then I get ImportError: cannot import name 'app' from 'app'
.
I would think that using your app
variable defined in app.py would be a common use case for writing tests so you can actually test the app you built. Or do I have to recreate the app
within each test I write, copying the definition from app.py, each time I want to access it? This seems a little redundant. Is there a better way?