From 6049048bbf41e001e5d11ec8c2acb4064595bc15 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Fri, 23 Dec 2022 11:24:40 +0100 Subject: [PATCH] fixed test --- .gitlab-ci.yml | 2 ++ test/main.py | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 49e8c5f..20ae5f0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,6 +18,8 @@ build: test: image: python:3.10-slim-bullseye stage: test + variables: + DATABASE: sqlite:///../app/db.sqlite before_script: - pip install -r requirements.txt - pip install pytest httpx diff --git a/test/main.py b/test/main.py index aeb52e3..aa9d644 100644 --- a/test/main.py +++ b/test/main.py @@ -1,13 +1,11 @@ from starlette.testclient import TestClient -import importlib.util 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) -main = importlib.util.module_from_spec(spec) -sys.modules[MODULE] = main -spec.loader.exec_module(main) +from app import main client = TestClient(main.app)