Sort generated flags before passing them to Borg.

This commit is contained in:
Dan Helfman 2019-06-25 11:04:10 -07:00
parent 86dbc00cbe
commit 56fd78089d
2 changed files with 3 additions and 5 deletions

View file

@ -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('_')
)
)

View file

@ -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():