Author: russellm
Date: 2009-11-18 22:35:31 -0600 (Wed, 18 Nov 2009)
New Revision: 11747

Modified:
   django/trunk/django/core/management/__init__.py
   django/trunk/tests/regressiontests/bash_completion/tests.py
Log:
Fixed #11243 -- Ensured that bash_completion output is emitted in sorted order. 
Thanks to Alex Gaynor for the report.

Modified: django/trunk/django/core/management/__init__.py
===================================================================
--- django/trunk/django/core/management/__init__.py     2009-11-18 21:39:07 UTC 
(rev 11746)
+++ django/trunk/django/core/management/__init__.py     2009-11-19 04:35:31 UTC 
(rev 11747)
@@ -299,7 +299,7 @@
 
         # 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 @@
             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

Modified: django/trunk/tests/regressiontests/bash_completion/tests.py
===================================================================
--- django/trunk/tests/regressiontests/bash_completion/tests.py 2009-11-18 
21:39:07 UTC (rev 11746)
+++ django/trunk/tests/regressiontests/bash_completion/tests.py 2009-11-19 
04:35:31 UTC (rev 11747)
@@ -65,7 +65,7 @@
         "Subcommands can be autocompleted"
         self._user_input('django-admin.py 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 @@
         self._user_input('django-admin.py 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')))

--

You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=.


Reply via email to