File size: 870 Bytes
4949db9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 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))
@pytest.fixture
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()
@pytest.fixture
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
@pytest.fixture
def client(app):
return app.test_client()
@pytest.fixture
def app_db(app):
from human_eval.app import get_app_db
with app.app_context():
yield get_app_db()
|