From 2618f4f50b753b9a5a81bec3da1735c101bf348c Mon Sep 17 00:00:00 2001 From: Arne Binder Date: Wed, 1 Nov 2023 18:58:02 +0100 Subject: [PATCH] import all src files to include them in the coverage score --- tests/conftest.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index 9bc14df7..c497bcbb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,7 @@ import dataclasses +import glob +import os +from pathlib import Path import pkg_resources import pytest @@ -9,6 +12,17 @@ from pytorch_ie.documents import TextBasedDocument from tests import FIXTURES_ROOT +from tests.dataset_builders.common import DATASET_BUILDER_BASE_PATH + +SRC_ROOTS = [Path("src"), DATASET_BUILDER_BASE_PATH] + +# import all src files to include them in the coverage score (and report) +# this is necessary because we calculate coverage by calling "pytest --cov" +for src_root in SRC_ROOTS: + for file in glob.glob(f"{src_root}/**/*.py", recursive=True): + import_path = file.replace(os.sep, ".").rstrip(".py") + __import__(import_path) + _TABULATE_AVAILABLE = "tabulate" in {pkg.key for pkg in pkg_resources.working_set}