Forráskód Böngészése

Merge pull request #1094 from enkore/stuff/tests

Travis workers hate him: improve testing speed with one simple trick
TW 9 éve
szülő
commit
7aed2d1d29
3 módosított fájl, 11 hozzáadás és 6 törlés
  1. 4 4
      borg/archiver.py
  2. 6 1
      conftest.py
  3. 1 1
      setup.py

+ 4 - 4
borg/archiver.py

@@ -96,9 +96,10 @@ def with_archive(method):
 
 
 class Archiver:
 class Archiver:
 
 
-    def __init__(self, lock_wait=None):
+    def __init__(self, lock_wait=None, prog=None):
         self.exit_code = EXIT_SUCCESS
         self.exit_code = EXIT_SUCCESS
         self.lock_wait = lock_wait
         self.lock_wait = lock_wait
+        self.parser = self.build_parser(prog)
 
 
     def print_error(self, msg, *args):
     def print_error(self, msg, *args):
         msg = args and msg % args or msg
         msg = args and msg % args or msg
@@ -1118,7 +1119,7 @@ class Archiver:
                     self.print_warning(warning)
                     self.print_warning(warning)
         return args
         return args
 
 
-    def build_parser(self, args=None, prog=None):
+    def build_parser(self, prog=None):
         common_parser = argparse.ArgumentParser(add_help=False, prog=prog)
         common_parser = argparse.ArgumentParser(add_help=False, prog=prog)
 
 
         common_group = common_parser.add_argument_group('Common options')
         common_group = common_parser.add_argument_group('Common options')
@@ -2062,8 +2063,7 @@ class Archiver:
         # We can't use argparse for "serve" since we don't want it to show up in "Available commands"
         # We can't use argparse for "serve" since we don't want it to show up in "Available commands"
         if args:
         if args:
             args = self.preprocess_args(args)
             args = self.preprocess_args(args)
-        parser = self.build_parser(args)
-        args = parser.parse_args(args or ['-h'])
+        args = self.parser.parse_args(args or ['-h'])
         update_excludes(args)
         update_excludes(args)
         return args
         return args
 
 

+ 6 - 1
conftest.py

@@ -27,7 +27,12 @@ setup_logging()
 
 
 from borg.testsuite import has_lchflags, no_lchlfags_because, has_llfuse
 from borg.testsuite import has_lchflags, no_lchlfags_because, has_llfuse
 from borg.testsuite.platform import fakeroot_detected
 from borg.testsuite.platform import fakeroot_detected
-from borg import xattr
+from borg import xattr, constants
+
+
+def pytest_configure(config):
+    # no fixture-based monkey-patching since star-imports are used for the constants module
+    constants.PBKDF2_ITERATIONS = 1
 
 
 
 
 def pytest_report_header(config, startdir):
 def pytest_report_header(config, startdir):

+ 1 - 1
setup.py

@@ -159,7 +159,7 @@ class build_usage(Command):
         print('generating usage docs')
         print('generating usage docs')
         # allows us to build docs without the C modules fully loaded during help generation
         # allows us to build docs without the C modules fully loaded during help generation
         from borg.archiver import Archiver
         from borg.archiver import Archiver
-        parser = Archiver().build_parser(prog='borg')
+        parser = Archiver(prog='borg').parser
         choices = {}
         choices = {}
         for action in parser._actions:
         for action in parser._actions:
             if action.choices is not None:
             if action.choices is not None: