Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fixed #11243 -- Ensured that bash_completion output is emitted in sor…

…ted order. Thanks to Alex Gaynor for the report.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 468ca16 commit 7875421a03a5af3006152216215fc3a9a9b8b274 @freakboy3742 freakboy3742 committed
4 django/core/management/
@@ -299,7 +299,7 @@ def autocomplete(self):
# subcommand
if cword == 1:
- print ' '.join(filter(lambda x: x.startswith(curr), subcommands))
+ print ' '.join(sorted(filter(lambda x: x.startswith(curr), subcommands)))
# subcommand options
# special case: the 'help' subcommand has no options
elif cwords[0] in subcommands and cwords[0] != 'help':
@@ -328,7 +328,7 @@ def autocomplete(self):
options = filter(lambda (x, v): x not in prev_opts, options)
# filter options by current input
- options = [(k, v) for k, v in options if k.startswith(curr)]
+ options = sorted([(k, v) for k, v in options if k.startswith(curr)])
for option in options:
opt_label = option[0]
# append '=' to options which require args
4 tests/regressiontests/bash_completion/
@@ -65,7 +65,7 @@ def test_subcommands(self):
"Subcommands can be autocompleted"
self._user_input(' sql')
output = self._run_autocomplete()
- self.assertEqual(output, ['sqlinitialdata sqlclear sqlreset sqlsequencereset sql sqlall sqlflush sqlcustom sqlindexes'])
+ self.assertEqual(output, ['sql sqlall sqlclear sqlcustom sqlflush sqlindexes sqlinitialdata sqlreset sqlsequencereset'])
def test_help(self):
"No errors, just an empty list if there are no autocomplete options"
@@ -84,4 +84,4 @@ def test_app_completion(self):
self._user_input(' sqlall a')
output = self._run_autocomplete()
app_labels = [name.split('.')[-1] for name in settings.INSTALLED_APPS]
- self.assertEqual(set(output), set(label for label in app_labels if label.startswith('a')))
+ self.assertEqual(output, sorted(label for label in app_labels if label.startswith('a')))

0 comments on commit 7875421

Please sign in to comment.
Something went wrong with that request. Please try again.