Skip to content

Commit 7fd871c

Browse files
jeffmakicyrossignol
authored andcommitted
Skip migrations when running tests
1 parent 934ce06 commit 7fd871c

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

@@ -57,6 +55,10 @@ async def lifespan(_app: FastAPI):
5755
)
5856
init_tdei_client()
5957

58+
# only run migrations when not under test
59+
if "pytest" not in sys.modules:
60+
run_migrations()
61+
6062
yield # App runs
6163

6264
# Run after app cleanup:

0 commit comments

Comments
 (0)