Repository: borgbackup/borg

Issue:
testsuite fail on Debian jessie
you can see the failures here
http://debomatic-amd64.debian.net/distribution#jessie-backports/borgbackup/1.0.8-1~bpo8+2/buildlog

or here
https://buildd.debian.org/status/package.php?p=borgbackup&suite=jessie-backports

```
APT_CONFIG=/var/lib/sbuild/apt.conf
HOME=/sbuild-nonexistent
LC_ALL=POSIX
LOGNAME=root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SCHROOT_ALIAS_NAME=jessie-backports-amd64-debomatic
SCHROOT_CHROOT_NAME=jessie-backports-amd64-debomatic
SCHROOT_COMMAND=env
SCHROOT_GID=0
SCHROOT_GROUP=root
SCHROOT_SESSION_ID=jessie-backports-amd64-debomatic-7cc2f830-032e-4b38-a10c-cd9e3842e9cb
SCHROOT_UID=0
SCHROOT_USER=root
SHELL=/bin/sh
USER=root
XDG_RUNTIME_DIR=/run/user/0
XDG_SESSION_ID=c23125
```
failing tests:
```
=================================== FAILURES ===================================
__________________ ArchiverTestCase.test_basic_functionality ___________________

self = <borg.testsuite.archiver.ArchiverTestCase testMethod=test_basic_functionality>

    def test_basic_functionality(self):
        have_root = self.create_test_files()
        self.cmd('init', self.repository_location)
        self.cmd('create', self.repository_location + '::test', 'input')
        self.cmd('create', '--stats', self.repository_location + '::test.2', 'input')
        with changedir('output'):
            self.cmd('extract', self.repository_location + '::test')
        list_output = self.cmd('list', '--short', self.repository_location)
        self.assert_in('test', list_output)
        self.assert_in('test.2', list_output)
        expected = [
            'input',
            'input/bdev',
            'input/cdev',
            'input/dir2',
            'input/dir2/file2',
            'input/empty',
            'input/fifo1',
            'input/file1',
            'input/flagfile',
            'input/hardlink',
            'input/link1',
        ]
        if not have_root:
            # we could not create these device files without (fake)root
            expected.remove('input/bdev')
            expected.remove('input/cdev')
        if has_lchflags:
            # remove the file we did not backup, so input and output become equal
            expected.remove('input/flagfile')  # this file is UF_NODUMP
            os.remove(os.path.join('input', 'flagfile'))
        list_output = self.cmd('list', '--short', self.repository_location + '::test')
        for name in expected:
            self.assert_in(name, list_output)
>       self.assert_dirs_equal('input', 'output/input')

borg/testsuite/archiver.py:352: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
borg/testsuite/__init__.py:65: in assert_dirs_equal
    self._assert_dirs_equal_cmp(diff, **kwargs)
borg/testsuite/__init__.py:102: in _assert_dirs_equal_cmp
    self.assert_equal(d1, d2)
E   AssertionError: Lists differ: ['dir2', 16749, 0, 0, None, 2, 1480371499251255642, {}] != ['dir2', 16877, 0, 0, None, 2, 1480371499251255642, {}]
E   
E   First differing element 1:
E   16749
E   16877
E   
E   - ['dir2', 16749, 0, 0, None, 2, 1480371499251255642, {}]
E   ?             ^^
E   
E   + ['dir2', 16877, 0, 0, None, 2, 1480371499251255642, {}]
E   ?            + ^
----------------------------- Captured stderr call -----------------------------
Warning: File system encoding is "ascii", extracting non-ascii filenames will not be supported.
Hint: You likely need to fix your locale setup. E.g. install locales and use: LANG=en_US.UTF-8
_______________ RemoteArchiverTestCase.test_basic_functionality ________________

self = <borg.testsuite.archiver.RemoteArchiverTestCase testMethod=test_basic_functionality>

    def test_basic_functionality(self):
        have_root = self.create_test_files()
        self.cmd('init', self.repository_location)
        self.cmd('create', self.repository_location + '::test', 'input')
        self.cmd('create', '--stats', self.repository_location + '::test.2', 'input')
        with changedir('output'):
            self.cmd('extract', self.repository_location + '::test')
        list_output = self.cmd('list', '--short', self.repository_location)
        self.assert_in('test', list_output)
        self.assert_in('test.2', list_output)
        expected = [
            'input',
            'input/bdev',
            'input/cdev',
            'input/dir2',
            'input/dir2/file2',
            'input/empty',
            'input/fifo1',
            'input/file1',
            'input/flagfile',
            'input/hardlink',
            'input/link1',
        ]
        if not have_root:
            # we could not create these device files without (fake)root
            expected.remove('input/bdev')
            expected.remove('input/cdev')
        if has_lchflags:
            # remove the file we did not backup, so input and output become equal
            expected.remove('input/flagfile')  # this file is UF_NODUMP
            os.remove(os.path.join('input', 'flagfile'))
        list_output = self.cmd('list', '--short', self.repository_location + '::test')
        for name in expected:
            self.assert_in(name, list_output)
>       self.assert_dirs_equal('input', 'output/input')

borg/testsuite/archiver.py:352: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
borg/testsuite/__init__.py:65: in assert_dirs_equal
    self._assert_dirs_equal_cmp(diff, **kwargs)
borg/testsuite/__init__.py:102: in _assert_dirs_equal_cmp
    self.assert_equal(d1, d2)
E   AssertionError: Lists differ: ['dir2', 16749, 0, 0, None, 2, 1480371547555535635, {}] != ['dir2', 16877, 0, 0, None, 2, 1480371547555535635, {}]
E   
E   First differing element 1:
E   16749
E   16877
E   
E   - ['dir2', 16749, 0, 0, None, 2, 1480371547555535635, {}]
E   ?             ^^
E   
E   + ['dir2', 16877, 0, 0, None, 2, 1480371547555535635, {}]
E   ?            + ^
----------------------------- Captured stderr call -----------------------------
Warning: File system encoding is "ascii", extracting non-ascii filenames will not be supported.
Hint: You likely need to fix your locale setup. E.g. install locales and use: LANG=en_US.UTF-8
______________________________ test_get_cache_dir ______________________________

monkeypatch = <_pytest.monkeypatch.monkeypatch object at 0x7fee6d3703c8>

    def test_get_cache_dir(monkeypatch):
        """test that get_cache_dir respects environment"""
        monkeypatch.delenv('XDG_CACHE_HOME', raising=False)
>       assert get_cache_dir() == os.path.join(os.path.expanduser('~'), '.cache', 'borg')
E       assert '/tmp/tmpmzvmry2k/cache' == '/build/borgbacku..._3.4/.cache/borg'
E         - /tmp/tmpmzvmry2k/cache
E         + /<<PKGBUILDDIR>>/.pybuild/pythonX.Y_3.4/.cache/borg

borg/testsuite/helpers.py:631: AssertionError
______________________________ test_get_keys_dir _______________________________

monkeypatch = <_pytest.monkeypatch.monkeypatch object at 0x7fee6c89d9b0>

    def test_get_keys_dir(monkeypatch):
        """test that get_keys_dir respects environment"""
        monkeypatch.delenv('XDG_CONFIG_HOME', raising=False)
>       assert get_keys_dir() == os.path.join(os.path.expanduser('~'), '.config', 'borg', 'keys')
E       assert '/tmp/tmpmzvmry2k/keys' == '/build/borgbacku....config/borg/keys'
E         - /tmp/tmpmzvmry2k/keys
E         + /<<PKGBUILDDIR>>/.pybuild/pythonX.Y_3.4/.config/borg/keys

borg/testsuite/helpers.py:641: AssertionError
 55 tests deselected by '-knot benchmark and not fuse_mount and not test_fuse' =
= 4 failed, 472 passed, 59 skipped, 55 deselected, 2 xpassed in 138.30 seconds =
E: pybuild pybuild:256: test: plugin distutils failed with: exit code=1: cd /<<PKGBUILDDIR>>/.pybuild/pythonX.Y_3.4/build; python3.4 -m pytest -k 'not benchmark and not fuse_mount and not test_fuse' --pyargs borg.testsuite
```

```
Kernel: Linux 4.4.0-0.bpo.1-amd64 amd64 (x86_64)
Toolchain package versions: binutils_2.25-5 dpkg-dev_1.17.27 g++-4.9_4.9.2-10 gcc-4.9_4.9.2-10 libc6-dev_2.19-18+deb8u6 libstdc++-4.9-dev_4.9.2-10 libstdc++6_4.9.2-10 linux-libc-dev_3.16.36-1+deb8u2
Package versions: acl_2.2.52-2 adduser_3.113+nmu3 apt_1.0.9.8.3 aptitude_0.6.11-1+b1 aptitude-common_0.6.11-1 base-files_8+deb8u6 base-passwd_3.5.37 bash_4.3-11+b1 binutils_2.25-5 bsdmainutils_9.0.6 bsdutils_1:2.25.2-6 build-essential_11.7 bzip2_1.0.6-7+b3 coreutils_8.23-4 cpp_4:4.9.2-2 cpp-4.9_4.9.2-10 cython3_0.21.1-1 dash_0.5.7-4+b1 debconf_1.5.56 debconf-i18n_1.5.56 debhelper_9.20150101+deb8u2 debian-archive-keyring_2014.3 debianutils_4.4+b1 dh-python_1.20141111-2 diffutils_1:3.3-1+b1 dmsetup_2:1.02.90-2.2+deb8u1 docutils-common_0.12+dfsg-1 dpkg_1.17.27 dpkg-dev_1.17.27 e2fslibs_1.42.12-2 e2fsprogs_1.42.12-2 fakeroot_1.20.2-1 file_1:5.22+15-2+deb8u2 findutils_4.4.2-9+b1 fonts-font-awesome_4.2.0~dfsg-1 g++_4:4.9.2-2 g++-4.9_4.9.2-10 gcc_4:4.9.2-2 gcc-4.8-base_4.8.4-1 gcc-4.9_4.9.2-10 gcc-4.9-base_4.9.2-10 gettext_0.19.3-2 gettext-base_0.19.3-2 gnupg_1.4.18-7+deb8u3 gpgv_1.4.18-7+deb8u3 grep_2.20-4.1 groff-base_1.22.2-8 gzip_1.6-4 hostname_3.15 init_1.22 initscripts_2.88dsf-59 insserv_1.14.0-5 intltool-debian_0.35.0+20060710.1 libacl1_2.2.52-2 libacl1-dev_2.2.52-2 libapt-pkg4.12_1.0.9.8.3 libasan1_4.9.2-10 libasprintf0c2_0.19.3-2 libatomic1_4.9.2-10 libattr1_1:2.4.47-2 libattr1-dev_1:2.4.47-2 libaudit-common_1:2.4-1 libaudit1_1:2.4-1+b1 libblkid1_2.25.2-6 libboost-iostreams1.55.0_1.55.0+dfsg-3 libbz2-1.0_1.0.6-7+b3 libc-bin_2.19-18+deb8u6 libc-dev-bin_2.19-18+deb8u6 libc6_2.19-18+deb8u6 libc6-dev_2.19-18+deb8u6 libcap2_1:2.24-8 libcap2-bin_1:2.24-8 libcilkrts5_4.9.2-10 libcloog-isl4_0.18.2-1+b2 libcomerr2_1.42.12-2 libcroco3_0.6.8-3+b1 libcryptsetup4_2:1.6.6-5 libcwidget3_0.5.17-2 libdb5.3_5.3.28-9 libdebconfclient0_0.192 libdevmapper1.02.1_2:1.02.90-2.2+deb8u1 libdpkg-perl_1.17.27 libexpat1_2.1.0-6+deb8u3 libexpat1-dev_2.1.0-6+deb8u3 libfakeroot_1.20.2-1 libffi6_3.1-2+b2 libfuse2_2.9.3-15+deb8u2 libgcc-4.9-dev_4.9.2-10 libgcc1_1:4.9.2-10 libgcrypt20_1.6.3-2+deb8u2 libgdbm3_1.8.3-13.1 libglib2.0-0_2.42.1-1+b1 libgmp10_2:6.0.0+dfsg-6 libgomp1_4.9.2-10 libgpg-error0_1.17-3 libisl10_0.12.2-2 libitm1_4.9.2-10 libjs-jquery_1.7.2+dfsg-3.2 libjs-sphinxdoc_1.2.3+dfsg-1 libjs-underscore_1.7.0~dfsg-1 libkmod2_18-3 liblocale-gettext-perl_1.05-8+b1 liblsan0_4.9.2-10 liblz4-1_0.0~r122-2 liblz4-dev_0.0~r122-2 liblzma5_5.1.1alpha+20120614-2+b3 libmagic1_1:5.22+15-2+deb8u2 libmount1_2.25.2-6 libmpc3_1.0.2-1 libmpdec2_2.4.1-1 libmpfr4_3.1.2-2 libncurses5_5.9+20140913-1+b1 libncursesw5_5.9+20140913-1+b1 libpam-modules_1.1.8-3.1+deb8u1+b1 libpam-modules-bin_1.1.8-3.1+deb8u1+b1 libpam-runtime_1.1.8-3.1+deb8u1 libpam0g_1.1.8-3.1+deb8u1+b1 libpcre3_2:8.35-3.3+deb8u4 libpipeline1_1.4.0-1 libprocps3_2:3.3.9-9 libpython3-dev_3.4.2-2 libpython3-stdlib_3.4.2-2 libpython3.4_3.4.2-1 libpython3.4-dev_3.4.2-1 libpython3.4-minimal_3.4.2-1 libpython3.4-stdlib_3.4.2-1 libquadmath0_4.9.2-10 libreadline6_6.3-8+b3 libselinux1_2.3-2 libsemanage-common_2.3-1 libsemanage1_2.3-1+b1 libsepol1_2.3-2 libsigc++-2.0-0c2a_2.4.0-1 libslang2_2.3.0-2 libsmartcols1_2.25.2-6 libsqlite3-0_3.8.7.1-1+deb8u2 libss2_1.42.12-2 libssl-dev_1.0.1t-1+deb8u5 libssl1.0.0_1.0.1t-1+deb8u5 libstdc++-4.9-dev_4.9.2-10 libstdc++6_4.9.2-10 libsystemd0_215-17+deb8u5 libtext-charwidth-perl_0.04-7+b3 libtext-iconv-perl_1.7-5+b2 libtext-wrapi18n-perl_0.06-7 libtimedate-perl_2.3000-2 libtinfo5_5.9+20140913-1+b1 libtsan0_4.9.2-10 libubsan0_4.9.2-10 libudev1_215-17+deb8u5 libunistring0_0.9.3-5.2+b1 libusb-0.1-4_2:0.1.12-25 libustr-1.0-1_1.0.4-3+b2 libuuid1_2.25.2-6 libxapian22_1.2.19-1+deb8u1 libxml2_2.9.1+dfsg1-5+deb8u3 linux-libc-dev_3.16.36-1+deb8u2 login_1:4.2-3+deb8u1 lsb-base_4.1+Debian13+nmu1 make_4.0-8.1 man-db_2.7.0.2-5 mawk_1.3.3-17 mime-support_3.58 mount_2.25.2-6 multiarch-support_2.19-18+deb8u6 ncurses-base_5.9+20140913-1 ncurses-bin_5.9+20140913-1+b1 passwd_1:4.2-3+deb8u1 patch_2.7.5-1 perl_5.20.2-3+deb8u6 perl-base_5.20.2-3+deb8u6 perl-modules_5.20.2-3+deb8u6 po-debconf_1.0.16+nmu3 procps_2:3.3.9-9 python3_3.4.2-2 python3-cov-core_1.14.0-1 python3-coverage_3.7.1+dfsg.1-1+b1 python3-dev_3.4.2-2 python3-docutils_0.12+dfsg-1 python3-jinja2_2.7.3-1 python3-llfuse_0.40-2+b2 python3-markupsafe_0.23-1+b1 python3-minimal_3.4.2-2 python3-msgpack_0.4.6-1~bpo8+1 python3-nose2_0.5.0-1 python3-pkg-resources_5.5.1-1 python3-py_1.4.25-1 python3-pygments_2.0.1+dfsg-1.1+deb8u1 python3-pytest_2.6.3-2 python3-pytest-cov_1.8.0-1 python3-roman_2.0.0-1 python3-setuptools_5.5.1-1 python3-setuptools-scm_1.10.1-2~bpo8+2 python3-six_1.8.0-1 python3-sphinx_1.2.3+dfsg-1 python3-sphinx-rtd-theme_0.1.6-1 python3.4_3.4.2-1 python3.4-dev_3.4.2-1 python3.4-minimal_3.4.2-1 readline-common_6.3-8 sbuild-build-depends-borgbackup-dummy_0.invalid.0 sbuild-build-depends-core-dummy_0.invalid.0 sed_4.2.2-4+b1 sensible-utils_0.0.9 sgml-base_1.26+nmu4 sphinx-common_1.2.3+dfsg-1 startpar_0.59-3 systemd_215-17+deb8u5 systemd-sysv_215-17+deb8u5 sysv-rc_2.88dsf-59 sysvinit-utils_2.88dsf-59 tar_1.27.1-2+deb8u1 tzdata_2016i-0+deb8u1 udev_215-17+deb8u5 util-linux_2.25.2-6 xml-core_0.13+nmu2 xz-utils_5.1.1alpha+20120614-2+b3 zlib1g_1:1.2.8.dfsg-2+b1 zlib1g-dev_1:1.2.8.dfsg-2+b1
```


Discussion:
I do test on jessie (using vagrant) when making releases, but did not see these errors yet.

Resolving patch:
diff --git a/borg/testsuite/helpers.py b/borg/testsuite/helpers.py
--- a/borg/testsuite/helpers.py
+++ b/borg/testsuite/helpers.py
@@ -627,6 +627,7 @@ def test(self):
 
 def test_get_cache_dir(monkeypatch):
     """test that get_cache_dir respects environment"""
+    monkeypatch.delenv('BORG_CACHE_DIR', raising=False)
     monkeypatch.delenv('XDG_CACHE_HOME', raising=False)
     assert get_cache_dir() == os.path.join(os.path.expanduser('~'), '.cache', 'borg')
     monkeypatch.setenv('XDG_CACHE_HOME', '/var/tmp/.cache')
@@ -637,6 +638,7 @@ def test_get_cache_dir(monkeypatch):
 
 def test_get_keys_dir(monkeypatch):
     """test that get_keys_dir respects environment"""
+    monkeypatch.delenv('BORG_KEYS_DIR', raising=False)
     monkeypatch.delenv('XDG_CONFIG_HOME', raising=False)
     assert get_keys_dir() == os.path.join(os.path.expanduser('~'), '.config', 'borg', 'keys')
     monkeypatch.setenv('XDG_CONFIG_HOME', '/var/tmp/.config')


Test patch: