mirror of
https://gitea.publichub.eu/oscar.krause/fastapi-dls.git
synced 2024-11-24 23:38:50 +00:00
fixed test
This commit is contained in:
parent
43d5736f37
commit
6049048bbf
@ -18,6 +18,8 @@ build:
|
|||||||
test:
|
test:
|
||||||
image: python:3.10-slim-bullseye
|
image: python:3.10-slim-bullseye
|
||||||
stage: test
|
stage: test
|
||||||
|
variables:
|
||||||
|
DATABASE: sqlite:///../app/db.sqlite
|
||||||
before_script:
|
before_script:
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- pip install pytest httpx
|
- pip install pytest httpx
|
||||||
|
10
test/main.py
10
test/main.py
@ -1,13 +1,11 @@
|
|||||||
from starlette.testclient import TestClient
|
from starlette.testclient import TestClient
|
||||||
import importlib.util
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
MODULE, PATH = 'main.app', '../app/main.py'
|
# add relative path to use packages as they were in the app/ dir
|
||||||
|
sys.path.append('../')
|
||||||
|
sys.path.append('../app')
|
||||||
|
|
||||||
spec = importlib.util.spec_from_file_location(MODULE, PATH)
|
from app import main
|
||||||
main = importlib.util.module_from_spec(spec)
|
|
||||||
sys.modules[MODULE] = main
|
|
||||||
spec.loader.exec_module(main)
|
|
||||||
|
|
||||||
client = TestClient(main.app)
|
client = TestClient(main.app)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user