Browse Source

Sort generated flags before passing them to Borg.

end-to-end-database-tests
Dan Helfman 2 years ago
parent
commit
56fd78089d
  1. 2
      borgmatic/borg/flags.py
  2. 6
      tests/unit/borg/test_flags.py

2
borgmatic/borg/flags.py

@ -25,7 +25,7 @@ def make_flags_from_arguments(arguments, excludes=()):
return tuple(
itertools.chain.from_iterable(
make_flags(name, value=getattr(arguments, name))
for name in vars(arguments)
for name in sorted(vars(arguments))
if name not in excludes and not name.startswith('_')
)
)

6
tests/unit/borg/test_flags.py

@ -23,16 +23,14 @@ def test_make_flags_formats_name_with_underscore():
assert module.make_flags('posix_me_harder', 'okay') == ('--posix-me-harder', 'okay')
def test_make_flags_from_arguments_flattens_multiple_arguments():
def test_make_flags_from_arguments_flattens_and_sorts_multiple_arguments():
flexmock(module).should_receive('make_flags').with_args('foo', 'bar').and_return(('foo', 'bar'))
flexmock(module).should_receive('make_flags').with_args('baz', 'quux').and_return(
('baz', 'quux')
)
arguments = flexmock(foo='bar', baz='quux')
assert sorted(module.make_flags_from_arguments(arguments)) == sorted(
('foo', 'bar', 'baz', 'quux')
)
assert module.make_flags_from_arguments(arguments) == ('baz', 'quux', 'foo', 'bar')
def test_make_flags_from_arguments_excludes_underscored_argument_names():

Loading…
Cancel
Save