diff --git a/image_prediction/locations.py b/image_prediction/locations.py index 1f14c1a..c6c314a 100644 --- a/image_prediction/locations.py +++ b/image_prediction/locations.py @@ -8,6 +8,8 @@ PACKAGE_ROOT_DIR = MODULE_DIR.parents[0] CONFIG_FILE = PACKAGE_ROOT_DIR / "config.yaml" +COVERAGERC = str(PACKAGE_ROOT_DIR / ".coveragerc") + BANNER_FILE = PACKAGE_ROOT_DIR / "banner.txt" DATA_DIR = PACKAGE_ROOT_DIR / "data" diff --git a/requirements.txt b/requirements.txt index 9cf8815..7c0f1ae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,3 +23,4 @@ pytest~=7.1.0 funcy==1.17 PyMuPDF==1.19.6 fpdf==1.7.2 +coverage==6.3.2 diff --git a/test/integration_tests/server_test.py b/test/integration_tests/server_test.py index b0befaa..831a835 100644 --- a/test/integration_tests/server_test.py +++ b/test/integration_tests/server_test.py @@ -1,12 +1,16 @@ +import os import socket from multiprocessing import Process -from time import sleep +import coverage import pytest import requests -from funcy import retry, complement +from funcy import retry from image_prediction.flask import make_prediction_server, run_prediction_server +from image_prediction.locations import COVERAGERC + +# os.environ['COVERAGE_PROCESS_START'] = COVERAGERC @pytest.fixture @@ -59,6 +63,7 @@ def server_ready(url): @pytest.fixture(autouse=True, scope="function") def server_process(server, host_and_port, url): def get_server_process(): + coverage.process_startup() return Process(target=run_prediction_server, kwargs={"app": server, **host_and_port}) server = get_server_process() @@ -67,7 +72,9 @@ def server_process(server, host_and_port, url): if server_ready(url): yield - server.terminate() + server.kill() + server.join() + server.close() def test_server_predict(url):