Fixed #7762 -- Hidden full script name in command error output
This commit is contained in:
parent
5949c2118d
commit
c24e979ece
|
@ -300,7 +300,8 @@ class BaseCommand(object):
|
||||||
for opt in self.option_list:
|
for opt in self.option_list:
|
||||||
parser.add_option(opt)
|
parser.add_option(opt)
|
||||||
else:
|
else:
|
||||||
parser = CommandParser(self, prog="%s %s" % (prog_name, subcommand), description=self.help or None)
|
parser = CommandParser(self, prog="%s %s" % (os.path.basename(prog_name), subcommand),
|
||||||
|
description=self.help or None)
|
||||||
parser.add_argument('--version', action='version', version=self.get_version())
|
parser.add_argument('--version', action='version', version=self.get_version())
|
||||||
parser.add_argument('-v', '--verbosity', action='store', dest='verbosity', default='1',
|
parser.add_argument('-v', '--verbosity', action='store', dest='verbosity', default='1',
|
||||||
type=int, choices=[0, 1, 2, 3],
|
type=int, choices=[0, 1, 2, 3],
|
||||||
|
|
|
@ -1417,6 +1417,14 @@ class CommandTypes(AdminScriptTestCase):
|
||||||
expected_labels = "('testlabel',)"
|
expected_labels = "('testlabel',)"
|
||||||
self._test_base_command(args, expected_labels, option_a="'x'", option_b="'y'")
|
self._test_base_command(args, expected_labels, option_a="'x'", option_b="'y'")
|
||||||
|
|
||||||
|
def test_base_command_with_wrong_option(self):
|
||||||
|
"User BaseCommands outputs command usage when wrong option is specified"
|
||||||
|
args = ['base_command', '--invalid']
|
||||||
|
out, err = self.run_manage(args)
|
||||||
|
self.assertNoOutput(out)
|
||||||
|
self.assertOutput(err, "usage: manage.py base_command")
|
||||||
|
self.assertOutput(err, "error: unrecognized arguments: --invalid")
|
||||||
|
|
||||||
def _test_base_command(self, args, labels, option_a="'1'", option_b="'2'"):
|
def _test_base_command(self, args, labels, option_a="'1'", option_b="'2'"):
|
||||||
out, err = self.run_manage(args)
|
out, err = self.run_manage(args)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue