Skip to content

Commit

Permalink
[1.2.X] Fixed #15359 -- Ensure that the -h option is always honored b…
Browse files Browse the repository at this point in the history
…y django-admin.py. Thanks to teubank for the report.

Backport of r15605 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Feb 21, 2011
1 parent bf4507f commit fee8a49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django/core/management/__init__.py
Expand Up @@ -372,7 +372,7 @@ def execute(self):
elif self.argv[1:] == ['--version']: elif self.argv[1:] == ['--version']:
# LaxOptionParser already takes care of printing the version. # LaxOptionParser already takes care of printing the version.
pass pass
elif self.argv[1:] == ['--help']: elif self.argv[1:] in (['--help'], ['-h']):
parser.print_lax_help() parser.print_lax_help()
sys.stderr.write(self.main_help_text() + '\n') sys.stderr.write(self.main_help_text() + '\n')
else: else:
Expand Down
10 changes: 10 additions & 0 deletions tests/regressiontests/admin_scripts/tests.py
Expand Up @@ -1031,6 +1031,16 @@ def test_help(self):
self.assertOutput(out, "Usage: manage.py subcommand [options] [args]") self.assertOutput(out, "Usage: manage.py subcommand [options] [args]")
self.assertOutput(err, "Type 'manage.py help <subcommand>' for help on a specific subcommand.") self.assertOutput(err, "Type 'manage.py help <subcommand>' for help on a specific subcommand.")


def test_short_help(self):
"-h is handled as a short form of --help"
args = ['-h']
out, err = self.run_manage(args)
if sys.version_info < (2, 5):
self.assertOutput(out, "usage: manage.py subcommand [options] [args]")
else:
self.assertOutput(out, "Usage: manage.py subcommand [options] [args]")
self.assertOutput(err, "Type 'manage.py help <subcommand>' for help on a specific subcommand.")

def test_specific_help(self): def test_specific_help(self):
"--help can be used on a specific command" "--help can be used on a specific command"
args = ['sqlall','--help'] args = ['sqlall','--help']
Expand Down

0 comments on commit fee8a49

Please sign in to comment.