[Tests] Better support when KiBot is also installed at user level

This commit is contained in:
Salvador E. Tropea 2022-07-09 16:26:46 -03:00
parent 35996e4cf5
commit 6ff6fcc975
5 changed files with 25 additions and 5 deletions

View File

@ -3,7 +3,11 @@ import os
import sys
# Setup the path to load local kibot module
prev_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
if prev_dir not in sys.path:
if sys.path[0] != prev_dir:
try:
sys.path.remove(prev_dir)
except ValueError:
pass
sys.path.insert(0, prev_dir)
# Force the pcbnew module load to fail
sys.modules['colorama'] = None

View File

@ -4,7 +4,11 @@ import sys
# Setup the path to load local kibot module
cur_dir = os.path.dirname(os.path.abspath(__file__))
prev_dir = os.path.dirname(os.path.dirname(cur_dir))
if prev_dir not in sys.path:
if sys.path[0] != prev_dir:
try:
sys.path.remove(prev_dir)
except ValueError:
pass
sys.path.insert(0, prev_dir)
if len(sys.argv) > 1 and sys.argv[1] == 'fake':
fake_dir = os.path.join(cur_dir, 'fake_pcbnew')

View File

@ -3,7 +3,11 @@ import os
import sys
# Setup the path to load local kibot module
prev_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
if prev_dir not in sys.path:
if sys.path[0] != prev_dir:
try:
sys.path.remove(prev_dir)
except ValueError:
pass
sys.path.insert(0, prev_dir)
# Force the xlsxwriter module load to fail
sys.modules['xlsxwriter'] = None

View File

@ -3,7 +3,11 @@ import os
import sys
# Setup the path to load local kibot module
prev_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
if prev_dir not in sys.path:
if sys.path[0] != prev_dir:
try:
sys.path.remove(prev_dir)
except ValueError:
pass
sys.path.insert(0, prev_dir)
# Force the pcbnew module load to fail
sys.modules['yaml'] = None

View File

@ -14,7 +14,11 @@ if prev_dir not in sys.path:
sys.path.insert(0, prev_dir)
# One more level for the project
prev_dir = os.path.dirname(prev_dir)
if prev_dir not in sys.path:
if sys.path[0] != prev_dir:
try:
sys.path.remove(prev_dir)
except ValueError:
pass
sys.path.insert(0, prev_dir)
import kibot.log as log