Repository: borgbackup/borg

Issue:
local tox testing on 1.0-maint broken
```
(borg-env) tw@tux:~/w/borg$ tox -e py34
GLOB sdist-make: /home/tw/w/borg/setup.py
py34 inst-nodeps: /home/tw/w/borg/.tox/dist/borgbackup-1.0.11.dev102+g6ce476a.zip
py34 installed: You are using pip version 7.1.2, however version 9.0.1 is available.,You should consider upgrading via the 'pip install --upgrade pip' command.,apipkg==1.4,Attic==0.16,borgbackup==1.0.11.dev102+g6ce476a,coverage==4.4.1,Cython==0.25.2,execnet==1.4.1,llfuse==1.2,msgpack-python==0.4.8,pluggy==0.4.0,py==1.4.34,pytest==3.1.2,pytest-benchmark==3.0.0,pytest-cov==2.5.1,pytest-xdist==1.17.1,setuptools-scm==1.15.6,tox==2.7.0,virtualenv==13.1.2,wheel==0.24.0
py34 runtests: PYTHONHASHSEED='2412370842'
py34 runtests: commands[0] | py.test -n 4 -rs --cov=borg --cov-config=../.coveragerc --benchmark-skip --pyargs borg.testsuite
Traceback (most recent call last):
  File "/home/tw/w/borg/.tox/py34/lib/python3.4/site-packages/_pytest/config.py", line 336, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/home/tw/w/borg/.tox')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/tw/w/borg/.tox/py34/lib/python3.4/site-packages/_pytest/config.py", line 367, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/home/tw/w/borg/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/tw/w/borg/.tox/py34/lib/python3.4/site-packages/_pytest/config.py", line 373, in _importconftest
    mod = conftestpath.pyimport()
  File "/home/tw/w/borg/.tox/py34/lib/python3.4/site-packages/py/_path/local.py", line 662, in pyimport
    __import__(modname)
  File "/home/tw/w/borg/.tox/py34/lib/python3.4/site-packages/_pytest/assertion/rewrite.py", line 215, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/home/tw/w/borg/conftest.py", line 7, in <module>
    import borg.cache
  File "/home/tw/w/borg/borg/cache.py", line 2, in <module>
    from .remote import cache_if_remote
  File "/home/tw/w/borg/borg/remote.py", line 15, in <module>
    from .helpers import Error, IntegrityError, sysinfo
  File "/home/tw/w/borg/borg/helpers.py", line 33, in <module>
    from . import hashindex
ImportError: cannot import name 'hashindex'
ERROR: could not load /home/tw/w/borg/conftest.py

ERROR: InvocationError: '/home/tw/w/borg/.tox/py34/bin/py.test -n 4 -rs --cov=borg --cov-config=../.coveragerc --benchmark-skip --pyargs borg.testsuite'
____________________________________________________________ summary ____________________________________________________________
ERROR:   py34: commands failed
```

Seems like this was introduced by 6ce476a42b7a6044fdaf8e0c97f8c8b1eb52b518 - that commit fails like seen above, the commit right before that works for me.


Discussion:
Interesting, I retried with just "tox":
```
ERROR:   py34: commands failed
  py35: commands succeeded
ERROR:   py36: commands failed
```
Note: 3.4 and 3.6 are from deadsnakes repo, 3.5 is the system (ubuntu 16.04) python.

@textshell can you have a look?
interesting: made a new virtualenv with python3.4, activated it, installed requirements + borg.

then:
```
$ tox
  py34: commands succeeded
  py35: commands succeeded
ERROR:   py36: commands failed
```

Resolving patch:
diff --git a/conftest.py b/conftest.py
--- a/conftest.py
+++ b/conftest.py
@@ -4,8 +4,6 @@
 
 import pytest
 
-import borg.cache
-
 # needed to get pretty assertion failures in unit tests:
 if hasattr(pytest, 'register_assert_rewrite'):
     pytest.register_assert_rewrite('borg.testsuite')
@@ -27,6 +25,9 @@
 except ImportError:
     sys.path = original_path
 
+# note: if anything from borg needs to be imported, do it below this line.
+import borg.cache
+
 
 @pytest.fixture(autouse=True)
 def clean_env(tmpdir_factory, monkeypatch):
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -270,8 +270,10 @@ def generate_level(self, prefix, parser, Archiver):
             'borg = borg.archiver:main',
         ]
     },
+    include_package_data=True,
     package_data={
-        'borg': ['paperkey.html']
+        'borg': ['paperkey.html'],
+        'borg.testsuite': ['attic.tar.gz'],
     },
     cmdclass=cmdclass,
     ext_modules=ext_modules,


Test patch: