diff --git a/tests/test_plot/__init__.py b/tests/test_plot/__init__.py index e2c5b0aa..415a1233 100644 --- a/tests/test_plot/__init__.py +++ b/tests/test_plot/__init__.py @@ -8,5 +8,10 @@ if prev_dir not in sys.path: # Utils import from utils import context # noqa: F401 prev_dir = os.path.dirname(prev_dir) -if prev_dir not in sys.path: +# py-test inserts things at the beginning, so we could end loading an installed copy of KiBot +if sys.path[0] != prev_dir: + try: + sys.path.remove(prev_dir) + except ValueError: + pass sys.path.insert(0, prev_dir) diff --git a/tests/utils/context.py b/tests/utils/context.py index bbc35320..d76cc3a6 100644 --- a/tests/utils/context.py +++ b/tests/utils/context.py @@ -11,7 +11,12 @@ from glob import glob from pty import openpty import xml.etree.ElementTree as ET prev_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -if prev_dir not in sys.path: +# py-test inserts things at the beginning, so we could end loading an installed copy of KiBot +if sys.path[0] != prev_dir: + try: + sys.path.remove(prev_dir) + except ValueError: + pass sys.path.insert(0, prev_dir) from kibot.misc import (error_level_to_name)