Merge pull request #9 from grillazz/switch-tests-to-anyio

enable anyio for unit tests
This commit is contained in:
Jakub Miazek 2021-11-27 19:23:33 +01:00 committed by GitHub
commit c8e5e01df5
3 changed files with 12 additions and 3 deletions

View File

@ -9,7 +9,7 @@ Example for [FastAPI](https://fastapi.tiangolo.com/) integration with [SQLAlchem
Beside of using latest and greatest version of [SQLAlchemy](https://www.sqlalchemy.org/) with it robustness, powerfulness and speed
of [asyncpg](https://github.com/MagicStack/asyncpg) there is [FastAPI](https://fastapi.tiangolo.com/) (modern, fast (high-performance),
web framework for building APIs with Python 3.9+ based on standard Python type hints.) already reviewed
web framework for building APIs with Python 3.10+ based on standard Python type hints.) already reviewed
on [thoughtworks](https://www.thoughtworks.com/radar/languages-and-frameworks?blipid=202104087).

View File

@ -4,8 +4,7 @@ import pytest
from fastapi import status
from httpx import AsyncClient
# decorate all tests with @pytest.mark.asyncio
pytestmark = pytest.mark.asyncio
pytestmark = pytest.mark.anyio
@pytest.mark.parametrize(

View File

@ -10,6 +10,16 @@ from the_app.database import get_db
from the_app.main import app
from the_app.models.base import Base
@pytest.fixture(
params=[
pytest.param(("asyncio", {"use_uvloop": True}), id="asyncio+uvloop"),
]
)
def anyio_backend(request):
return request.param
global_settings = config.get_settings()
url = global_settings.asyncpg_test_url
engine = create_async_engine(url, poolclass=NullPool, future=True)