MCPcopy
hub / github.com/pallets/flask / app

Function app

examples/tutorial/tests/conftest.py:16–32  ·  view source on GitHub ↗

Create and configure a new app instance for each test.

()

Source from the content-addressed store, hash-verified

14
15@pytest.fixture
16def app():
17 """Create and configure a new app instance for each test."""
18 # create a temporary file to isolate the database for each test
19 db_fd, db_path = tempfile.mkstemp()
20 # create the app with common test config
21 app = create_app({"TESTING": True, "DATABASE": db_path})
22
23 # create the database and load test data
24 with app.app_context():
25 init_db()
26 get_db().executescript(_data_sql)
27
28 yield app
29
30 # close and remove the temporary database
31 os.close(db_fd)
32 os.unlink(db_path)
33
34
35@pytest.fixture

Callers

nothing calls this directly

Calls 5

create_appFunction · 0.90
init_dbFunction · 0.90
get_dbFunction · 0.90
app_contextMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected