mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 01:06:50 +00:00
--progress option was backwards
adds unit tests and ensures we detect --progress correctly in all cases
This commit is contained in:
parent
a7eb83efa5
commit
a40729f4f3
2 changed files with 23 additions and 1 deletions
|
@ -775,7 +775,7 @@ class ToggleAction(argparse.Action):
|
|||
"""
|
||||
def __call__(self, parser, ns, values, option):
|
||||
"""set the given flag to true unless ``--no`` is passed"""
|
||||
setattr(ns, self.dest, option.startswith('--no-'))
|
||||
setattr(ns, self.dest, not option.startswith('--no-'))
|
||||
|
||||
subparser = subparsers.add_parser('create', parents=[common_parser],
|
||||
description=self.do_create.__doc__,
|
||||
|
|
|
@ -669,6 +669,28 @@ def test_create_dry_run(self):
|
|||
manifest, key = Manifest.load(repository)
|
||||
self.assert_equal(len(manifest.archives), 0)
|
||||
|
||||
def test_progress(self):
|
||||
self.create_regular_file('file1', size=1024 * 80)
|
||||
self.cmd('init', self.repository_location)
|
||||
# without a terminal, no progress expected
|
||||
output = self.cmd('create', self.repository_location + '::test1', 'input', fork=False)
|
||||
self.assert_not_in("\r", output)
|
||||
# with a terminal, progress expected
|
||||
output = self.cmd('create', self.repository_location + '::test2', 'input', fork=True)
|
||||
self.assert_in("\r", output)
|
||||
# without a terminal, progress forced on
|
||||
output = self.cmd('create', '--progress', self.repository_location + '::test3', 'input', fork=False)
|
||||
self.assert_in("\r", output)
|
||||
# with a terminal, progress forced on
|
||||
output = self.cmd('create', '--progress', self.repository_location + '::test4', 'input', fork=True)
|
||||
self.assert_in("\r", output)
|
||||
# without a termainl, progress forced off
|
||||
output = self.cmd('create', '--no-progress', self.repository_location + '::test5', 'input', fork=False)
|
||||
self.assert_not_in("\r", output)
|
||||
# with a termainl, progress forced off
|
||||
output = self.cmd('create', '--no-progress', self.repository_location + '::test6', 'input', fork=True)
|
||||
self.assert_not_in("\r", output)
|
||||
|
||||
def test_cmdline_compatibility(self):
|
||||
self.create_regular_file('file1', size=1024 * 80)
|
||||
self.cmd('init', self.repository_location)
|
||||
|
|
Loading…
Reference in a new issue