Skip to content

Commit

Permalink
fix: pytest sqlalchemy logs, additional deprecation warns
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Oct 12, 2023
1 parent 408441b commit 94a5c01
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with FMTM. If not, see <https:#www.gnu.org/licenses/>.
#

import logging
from typing import Any, Generator

import pytest
Expand All @@ -31,11 +32,18 @@
from app.db.db_models import DbOrganisation, DbProject, DbUser
from app.main import api, get_application

engine = create_engine(settings.FMTM_DB_URL)
engine = create_engine(settings.FMTM_DB_URL.unicode_string())
TestingSessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base.metadata.create_all(bind=engine)


def pytest_configure(config):
"""Configure pytest runs."""
# Stop sqlalchemy logs
sqlalchemy_log = logging.getLogger("sqlalchemy")
sqlalchemy_log.propagate = False


@pytest.fixture(autouse=True)
def app() -> Generator[FastAPI, Any, None]:
"""Create a fresh database on each test case."""
Expand All @@ -44,7 +52,7 @@ def app() -> Generator[FastAPI, Any, None]:

@pytest.fixture(scope="session")
def db_engine():
engine = create_engine(settings.FMTM_DB_URL)
engine = create_engine(settings.FMTM_DB_URL.unicode_string())
if not database_exists:
create_database(engine.url)

Expand Down

0 comments on commit 94a5c01

Please sign in to comment.