27 lines
581 B
Python
27 lines
581 B
Python
from typing import Generator
|
|
|
|
import pytest
|
|
from flask import Flask
|
|
from flask.testing import FlaskClient
|
|
from flask.ctx import AppContext
|
|
|
|
from ..app import create_app
|
|
from ..app.dependencies import db
|
|
|
|
|
|
@pytest.fixture()
|
|
def test_app() -> Generator[Flask, None, None]:
|
|
yield create_app("testing")
|
|
|
|
|
|
@pytest.fixture()
|
|
def test_app_ctx_with_db(test_app) -> Generator[AppContext, None, None]:
|
|
with test_app.app_context() as ctx:
|
|
db.create_all()
|
|
yield ctx
|
|
|
|
|
|
@pytest.fixture()
|
|
def test_client(test_app: Flask) -> FlaskClient:
|
|
return test_app.test_client()
|