Create and configure a new app instance for each test.
()
| 14 | |
| 15 | @pytest.fixture |
| 16 | def 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 |
nothing calls this directly
no test coverage detected