From e29c7b2a930d4f52bba402e97fed07d31c172e15 Mon Sep 17 00:00:00 2001 From: SET Date: Sat, 15 Aug 2020 15:25:02 -0300 Subject: [PATCH] Fixed tests adding to sys.path unconditionally --- tests/test_plot/test_sch_errors.py | 9 ++++++--- tests/test_plot/test_yaml_errors.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/test_plot/test_sch_errors.py b/tests/test_plot/test_sch_errors.py index ba562539..c07e7325 100644 --- a/tests/test_plot/test_sch_errors.py +++ b/tests/test_plot/test_sch_errors.py @@ -9,11 +9,14 @@ pytest-3 --log-cli-level debug import os import sys # Look for the 'utils' module from where the script is running -prev_dir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.dirname(prev_dir)) +prev_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +if prev_dir not in sys.path: + sys.path.insert(0, prev_dir) # Utils import from utils import context -sys.path.insert(0, os.path.dirname(prev_dir)) +prev_dir = os.path.dirname(prev_dir) +if prev_dir not in sys.path: + sys.path.insert(0, prev_dir) from kiplot.misc import CORRUPTED_SCH diff --git a/tests/test_plot/test_yaml_errors.py b/tests/test_plot/test_yaml_errors.py index 7dc7c856..d0ae3302 100644 --- a/tests/test_plot/test_yaml_errors.py +++ b/tests/test_plot/test_yaml_errors.py @@ -51,11 +51,14 @@ pytest-3 --log-cli-level debug import os import sys # Look for the 'utils' module from where the script is running -prev_dir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, os.path.dirname(prev_dir)) +prev_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +if prev_dir not in sys.path: + sys.path.insert(0, prev_dir) # Utils import from utils import context -sys.path.insert(0, os.path.dirname(prev_dir)) +prev_dir = os.path.dirname(prev_dir) +if prev_dir not in sys.path: + sys.path.insert(0, prev_dir) from kiplot.misc import (EXIT_BAD_CONFIG, PLOT_ERROR, BOM_ERROR)