aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/tests/shiboken_paths.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/tests/shiboken_paths.py')
-rw-r--r--sources/shiboken2/tests/shiboken_paths.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/sources/shiboken2/tests/shiboken_paths.py b/sources/shiboken2/tests/shiboken_paths.py
index 1f60baac2..ba0da9189 100644
--- a/sources/shiboken2/tests/shiboken_paths.py
+++ b/sources/shiboken2/tests/shiboken_paths.py
@@ -76,10 +76,15 @@ def _prepend_path_var(var_name, paths):
def add_python_dirs(python_dirs):
- """Add directories to the Python path unless present."""
+ """Add directories to the Python path unless present.
+ Care is taken that the added directories come before
+ site-packages."""
+ new_paths = []
for python_dir in python_dirs:
- if python_dir not in sys.path:
- sys.path.append(python_dir)
+ new_paths.append(python_dir)
+ if python_dir in sys.path:
+ sys.path.remove(python_dir)
+ sys.path[:0] = new_paths
def add_lib_dirs(lib_dirs):