| import sqlite3 | |
| import pytest | |
| import sys | |
| from pathlib import Path | |
| EVAL_ROOT = Path(__file__).resolve().parent.parent.parent | |
| if str(EVAL_ROOT) not in sys.path: | |
| sys.path.append(str(EVAL_ROOT)) | |
| def db(): | |
| from human_eval.db import init_db | |
| conn = sqlite3.connect(":memory:") | |
| conn.row_factory = sqlite3.Row | |
| init_db(conn) | |
| yield conn | |
| conn.close() | |
| def app(tmp_path): | |
| pytest.importorskip("flask") | |
| from human_eval.app import create_app | |
| test_app = create_app( | |
| db_path=":memory:", | |
| video_data_dir=tmp_path, | |
| skip_import=True, | |
| ) | |
| test_app.config["TESTING"] = True | |
| yield test_app | |
| def client(app): | |
| return app.test_client() | |
| def app_db(app): | |
| from human_eval.app import get_app_db | |
| with app.app_context(): | |
| yield get_app_db() | |