Fixed #28524 -- Fixed program name in management commands when using 'python -m django'.
This commit is contained in:
parent
f0d9ede9e6
commit
ec6481246a
|
@ -149,6 +149,8 @@ class ManagementUtility:
|
||||||
def __init__(self, argv=None):
|
def __init__(self, argv=None):
|
||||||
self.argv = argv or sys.argv[:]
|
self.argv = argv or sys.argv[:]
|
||||||
self.prog_name = os.path.basename(self.argv[0])
|
self.prog_name = os.path.basename(self.argv[0])
|
||||||
|
if self.prog_name == '__main__.py':
|
||||||
|
self.prog_name = 'python -m django'
|
||||||
self.settings_exception = None
|
self.settings_exception = None
|
||||||
|
|
||||||
def main_help_text(self, commands_only=False):
|
def main_help_text(self, commands_only=False):
|
||||||
|
|
|
@ -2223,3 +2223,7 @@ class MainModule(AdminScriptTestCase):
|
||||||
cmd_out, _ = self.run_django_admin(['--version'])
|
cmd_out, _ = self.run_django_admin(['--version'])
|
||||||
mod_out, _ = self.run_test('-m', ['django', '--version'])
|
mod_out, _ = self.run_test('-m', ['django', '--version'])
|
||||||
self.assertEqual(mod_out, cmd_out)
|
self.assertEqual(mod_out, cmd_out)
|
||||||
|
|
||||||
|
def test_program_name_in_help(self):
|
||||||
|
out, err = self.run_test('-m', ['django', 'help'])
|
||||||
|
self.assertOutput(out, "Type 'python -m django help <subcommand>' for help on a specific subcommand.")
|
||||||
|
|
Loading…
Reference in New Issue