Skip to content

Commit 4961e4b

Browse files
jeffmakicyrossignol
authored andcommitted
Skip migrations when running tests
1 parent 934ce06 commit 4961e4b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

api/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import re
3+
import sys
34
from contextlib import asynccontextmanager
45

56
import httpx
@@ -36,9 +37,6 @@
3637
# Set up logging configuration
3738
setup_logging()
3839

39-
# Optional: Run migrations on startup
40-
run_migrations()
41-
4240
# Set up logger for this module
4341
logger = get_logger(__name__)
4442

@@ -48,6 +46,10 @@
4846

4947
@asynccontextmanager
5048
async def lifespan(_app: FastAPI):
49+
# only run migrations when not under test
50+
if "pytest" not in sys.modules:
51+
run_migrations()
52+
5153
# Run before app bootstrap:
5254
global _osm_client
5355
_osm_client = httpx.AsyncClient(

0 commit comments

Comments
 (0)