From 0bbc14f54b4d35d809e62774cf6be77bb95215db Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 14 Aug 2024 13:19:46 +0200 Subject: [PATCH] ci: when running pytest, make sure that 'import yunohost' will load the code being tested, not the one from /usr/lib/python3/dist-packages ? --- src/tests/conftest.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tests/conftest.py b/src/tests/conftest.py index 246ae29b7..082b51843 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -68,10 +68,13 @@ moulinette.core.Translator.translate = new_translate def pytest_cmdline_main(config): import sys + from pathlib import Path + + # Tweak python path such that "import yunohost" imports "this" code and not the one from /usr/lib/python3/dist-packages + code_root = str(Path(__file__).parent.parent.parent) + sys.path.insert(0, code_root) - sys.path.insert(0, "/usr/lib/moulinette/") import yunohost - yunohost.init() class DummyInterface: