From d3e85cea9013c49eb20ae8c64fe935009e5812ba Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Mon, 4 Sep 2023 17:39:55 +0200
Subject: [PATCH] Fixed Python coverage

---
 .gitlab/ci/coverage.gitlab-ci.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.gitlab/ci/coverage.gitlab-ci.yml b/.gitlab/ci/coverage.gitlab-ci.yml
index 343db90d..33547fc3 100644
--- a/.gitlab/ci/coverage.gitlab-ci.yml
+++ b/.gitlab/ci/coverage.gitlab-ci.yml
@@ -28,7 +28,9 @@ coverage:ubuntu_python:
     - source venv/bin/activate
     - python3 -m pip install numpy coverage
     - cd ${CI_PROJECT_NAME}
-    - python3 -m coverage run --source=. -m unittest discover -s unit_tests/ -v -b
+    # Retrieve the installation path of the module, since it is installed with pip.
+    - export MODULE_LOCATION=`python -c "import ${CI_PROJECT_NAME} as _; print(_.__path__[0])"`
+    - python3 -m coverage run --source=$MODULE_LOCATION -m unittest discover -s unit_tests/ -v -b
     - python3 -m coverage report
     - python3 -m coverage xml
   coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
-- 
GitLab