Skip to content

Commit

Permalink
import all src files to include them in the coverage score
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBinder committed Nov 1, 2023
1 parent fed3e23 commit 2618f4f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import dataclasses
import glob
import os
from pathlib import Path

import pkg_resources
import pytest
Expand All @@ -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}

Expand Down

0 comments on commit 2618f4f

Please sign in to comment.