conftest.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import sys
  2. # This is a hack to fix path problems because "borg" (the package) is in the source root.
  3. # When importing the conftest an "import borg" can incorrectly import the borg from the
  4. # source root instead of the one installed in the environment.
  5. # The workaround is to remove entries pointing there from the path and check whether "borg"
  6. # is still importable. If it is not, then it has not been installed in the environment
  7. # and the entries are put back.
  8. #
  9. # TODO: After moving the package to src/: remove this.
  10. original_path = list(sys.path)
  11. for entry in original_path:
  12. if entry == '' or entry.endswith('/borg'):
  13. sys.path.remove(entry)
  14. try:
  15. import borg
  16. except ImportError:
  17. sys.path = original_path
  18. from borg.logger import setup_logging
  19. # Ensure that the loggers exist for all tests
  20. setup_logging()
  21. from borg.testsuite import has_lchflags, no_lchlfags_because, has_llfuse
  22. from borg.testsuite.platform import fakeroot_detected
  23. from borg import xattr
  24. def pytest_report_header(config, startdir):
  25. yesno = ['no', 'yes']
  26. flags = 'Testing BSD-style flags: %s %s' % (yesno[has_lchflags], no_lchlfags_because)
  27. fakeroot = 'fakeroot: %s (>=1.20.2: %s)' % (
  28. yesno[fakeroot_detected()],
  29. yesno[xattr.XATTR_FAKEROOT])
  30. llfuse = 'Testing fuse: %s' % yesno[has_llfuse]
  31. return '\n'.join((flags, llfuse, fakeroot))