mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-22 15:28:57 +00:00
add conftest.py hack needed for borg 1.0.x
This commit is contained in:
parent
f3efcdbd2e
commit
2679963cb9
1 changed files with 21 additions and 0 deletions
21
conftest.py
21
conftest.py
|
@ -1,8 +1,29 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_env(tmpdir_factory, monkeypatch):
|
||||
# avoid that we access / modify the user's normal .config / .cache directory:
|
||||
|
|
Loading…
Reference in a new issue