1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-06 11:40:31 +00:00

Merge pull request #1057 from enkore/issue/1055

Fix tox
This commit is contained in:
TW 2016-05-18 17:39:01 +02:00
commit 088bccc649

View file

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