summaryrefslogtreecommitdiffstats
path: root/conftest.py
diff options
context:
space:
mode:
authorMarian Beermann <public@enkore.de>2016-05-18 17:08:45 +0200
committerMarian Beermann <public@enkore.de>2016-05-18 17:08:49 +0200
commit43258abf2117a44238044587501e5a1a1e383dca (patch)
treeb01eba01eb4ea22c014b9ffed3c1ae146d868eea /conftest.py
parentac2617f6652880975d191c0cb44e881f3dcea83c (diff)
Fix tox
Diffstat (limited to 'conftest.py')
-rw-r--r--conftest.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/conftest.py b/conftest.py
index 44ff5cde9..6ca799a3e 100644
--- a/conftest.py
+++ b/conftest.py
@@ -1,3 +1,24 @@
+import sys
+
+# This is a hack to fix path problems because "borg" (the package) is in the source root.
+# When importing the conftest an "import borg" can incorrectly import the borg from the
+# source root instead of the one installed in the environment.
+# The workaround is to remove entries pointing there from the path and check whether "borg"
+# is still importable. If it is not, then it has not been installed in the environment
+# and the entries are put back.
+#
+# TODO: After moving the package to src/: remove this.
+
+original_path = list(sys.path)
+for entry in original_path:
+ if entry == '' or entry.endswith('/borg'):
+ sys.path.remove(entry)
+
+try:
+ import borg
+except ImportError:
+ sys.path = original_path
+
from borg.logger import setup_logging
# Ensure that the loggers exist for all tests