From 85a7750d09989f8c3121f8eed03824194382773b Mon Sep 17 00:00:00 2001 From: stijndcl Date: Thu, 23 Jun 2022 11:53:21 +0200 Subject: [PATCH] No longer run migrations in tests --- tests/conftest.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index c2c5e0a..6c04eb6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,11 +3,10 @@ from typing import AsyncGenerator, Generator from unittest.mock import MagicMock import pytest - -from alembic import command, config from sqlalchemy.ext.asyncio import AsyncSession from database.engine import engine +from database.models import Base from didier import Didier @@ -19,15 +18,12 @@ def event_loop() -> Generator: @pytest.fixture(scope="session") -def tables(event_loop): - """Initialize a database before the tests, and then tear it down again - Starts from an empty database and runs through all the migrations to check those as well - while we're at it - """ - alembic_config = config.Config("alembic.ini") - command.upgrade(alembic_config, "head") - yield - command.downgrade(alembic_config, "base") +async def tables(event_loop): + """Initialize a database before the tests, and then tear it down again""" + async with engine.begin() as connection: + await connection.run_sync(Base.metadata.create_all) + yield + await connection.run_sync(Base.metadata.drop_all) @pytest.fixture