Fixed problems when running tests and a copy of KiBot is in ~/.local

This commit is contained in:
Salvador E. Tropea 2022-07-06 19:14:58 -03:00
parent 420757880f
commit 56f5176060
2 changed files with 12 additions and 2 deletions

View File

@ -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)

View File

@ -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)