Ticket #9158: django-admin-stdout_with_test.diff

File django-admin-stdout_with_test.diff, 2.2 KB (added by Dario Ocles, 14 years ago)

Print just help info to stdout, print real errors to stderr. Fixed tests

  • tests/regressiontests/admin_scripts/tests.py

     
    11131113            self.assertOutput(out, "usage: manage.py subcommand [options] [args]")
    11141114        else:
    11151115            self.assertOutput(out, "Usage: manage.py subcommand [options] [args]")
    1116         self.assertOutput(err, "Type 'manage.py help <subcommand>' for help on a specific subcommand.")
     1116        self.assertOutput(out, "Type 'manage.py help <subcommand>' for help on a specific subcommand.")
    11171117
    11181118    def test_short_help(self):
    11191119        "-h is handled as a short form of --help"
     
    11231123            self.assertOutput(out, "usage: manage.py subcommand [options] [args]")
    11241124        else:
    11251125            self.assertOutput(out, "Usage: manage.py subcommand [options] [args]")
    1126         self.assertOutput(err, "Type 'manage.py help <subcommand>' for help on a specific subcommand.")
     1126        self.assertOutput(out, "Type 'manage.py help <subcommand>' for help on a specific subcommand.")
    11271127
    11281128    def test_specific_help(self):
    11291129        "--help can be used on a specific command"
  • django/core/management/__init__.py

     
    365365                self.fetch_command(args[2]).print_help(self.prog_name, args[2])
    366366            else:
    367367                parser.print_lax_help()
    368                 sys.stderr.write(self.main_help_text() + '\n')
     368                sys.stdout.write(self.main_help_text() + '\n')
    369369                sys.exit(1)
    370370        # Special-cases: We want 'django-admin.py --version' and
    371371        # 'django-admin.py --help' to work, for backwards compatibility.
     
    374374            pass
    375375        elif self.argv[1:] in (['--help'], ['-h']):
    376376            parser.print_lax_help()
    377             sys.stderr.write(self.main_help_text() + '\n')
     377            sys.stdout.write(self.main_help_text() + '\n')
    378378        else:
    379379            self.fetch_command(subcommand).run_from_argv(self.argv)
    380380
Back to Top