Fixed #22835 -- Deprecated NoArgsCommand.

This commit is contained in:
Maxime Turcotte 2014-06-17 19:07:54 -04:00 committed by Tim Graham
parent 63670a474c
commit 9996158db4
20 changed files with 94 additions and 69 deletions

View File

@ -1,13 +1,13 @@
from importlib import import_module from importlib import import_module
from django.conf import settings from django.conf import settings
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
class Command(NoArgsCommand): class Command(BaseCommand):
help = "Can be run as a cronjob or directly to clean out expired sessions (only with the database backend at the moment)." help = "Can be run as a cronjob or directly to clean out expired sessions (only with the database backend at the moment)."
def handle_noargs(self, **options): def handle(self, **options):
engine = import_module(settings.SESSION_ENGINE) engine = import_module(settings.SESSION_ENGINE)
try: try:
engine.SessionStore.clear_expired() engine.SessionStore.clear_expired()

View File

@ -4,7 +4,8 @@ import os
from collections import OrderedDict from collections import OrderedDict
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
from django.core.management.base import CommandError, NoArgsCommand from django.core.management.base import CommandError, BaseCommand
from django.core.management.color import no_style
from django.utils.encoding import smart_text from django.utils.encoding import smart_text
from django.utils.six.moves import input from django.utils.six.moves import input
@ -12,7 +13,7 @@ from django.contrib.staticfiles.finders import get_finders
from django.contrib.staticfiles.storage import staticfiles_storage from django.contrib.staticfiles.storage import staticfiles_storage
class Command(NoArgsCommand): class Command(BaseCommand):
""" """
Command that allows to copy or symlink static files from different Command that allows to copy or symlink static files from different
locations to the settings.STATIC_ROOT. locations to the settings.STATIC_ROOT.
@ -21,12 +22,13 @@ class Command(NoArgsCommand):
requires_system_checks = False requires_system_checks = False
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(NoArgsCommand, self).__init__(*args, **kwargs) super(BaseCommand, self).__init__(*args, **kwargs)
self.copied_files = [] self.copied_files = []
self.symlinked_files = [] self.symlinked_files = []
self.unmodified_files = [] self.unmodified_files = []
self.post_processed_files = [] self.post_processed_files = []
self.storage = staticfiles_storage self.storage = staticfiles_storage
self.style = no_style()
try: try:
self.storage.path('') self.storage.path('')
except NotImplementedError: except NotImplementedError:
@ -79,7 +81,7 @@ class Command(NoArgsCommand):
""" """
Perform the bulk of the work of collectstatic. Perform the bulk of the work of collectstatic.
Split off from handle_noargs() to facilitate testing. Split off from handle() to facilitate testing.
""" """
if self.symlink and not self.local: if self.symlink and not self.local:
raise CommandError("Can't symlink to a remote destination.") raise CommandError("Can't symlink to a remote destination.")
@ -130,7 +132,7 @@ class Command(NoArgsCommand):
'post_processed': self.post_processed_files, 'post_processed': self.post_processed_files,
} }
def handle_noargs(self, **options): def handle(self, **options):
self.set_options(**options) self.set_options(**options)
message = ['\n'] message = ['\n']

View File

@ -603,6 +603,14 @@ class NoArgsCommand(BaseCommand):
""" """
args = '' args = ''
def __init__(self):
warnings.warn(
"NoArgsCommand class is deprecated and will be removed in Django 2.0. "
"Use BaseCommand instead, which takes no arguments by default.",
RemovedInDjango20Warning
)
super(NoArgsCommand, self).__init__()
def handle(self, *args, **options): def handle(self, *args, **options):
if args: if args:
raise CommandError("Command doesn't accept any arguments") raise CommandError("Command doesn't accept any arguments")

View File

@ -1,4 +1,4 @@
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
def module_to_dict(module, omittable=lambda k: k.startswith('_')): def module_to_dict(module, omittable=lambda k: k.startswith('_')):
@ -6,7 +6,7 @@ def module_to_dict(module, omittable=lambda k: k.startswith('_')):
return dict((k, repr(v)) for k, v in module.__dict__.items() if not omittable(k)) return dict((k, repr(v)) for k, v in module.__dict__.items() if not omittable(k))
class Command(NoArgsCommand): class Command(BaseCommand):
help = """Displays differences between the current settings.py and Django's help = """Displays differences between the current settings.py and Django's
default settings. Settings that don't appear in the defaults are default settings. Settings that don't appear in the defaults are
followed by "###".""" followed by "###"."""
@ -18,7 +18,7 @@ class Command(NoArgsCommand):
help='Display all settings, regardless of their value. ' help='Display all settings, regardless of their value. '
'Default values are prefixed by "###".') 'Default values are prefixed by "###".')
def handle_noargs(self, **options): def handle(self, **options):
# Inspired by Postfix's "postconf -n". # Inspired by Postfix's "postconf -n".
from django.conf import settings, global_settings from django.conf import settings, global_settings

View File

@ -4,14 +4,14 @@ from importlib import import_module
from django.apps import apps from django.apps import apps
from django.db import connections, router, transaction, DEFAULT_DB_ALIAS from django.db import connections, router, transaction, DEFAULT_DB_ALIAS
from django.core.management import call_command from django.core.management import call_command
from django.core.management.base import NoArgsCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.core.management.color import no_style from django.core.management.color import no_style
from django.core.management.sql import sql_flush, emit_post_migrate_signal from django.core.management.sql import sql_flush, emit_post_migrate_signal
from django.utils.six.moves import input from django.utils.six.moves import input
from django.utils import six from django.utils import six
class Command(NoArgsCommand): class Command(BaseCommand):
help = ('Removes ALL DATA from the database, including data added during ' help = ('Removes ALL DATA from the database, including data added during '
'migrations. Unmigrated apps will also have their initial_data ' 'migrations. Unmigrated apps will also have their initial_data '
'fixture reloaded. Does not achieve a "fresh install" state.') 'fixture reloaded. Does not achieve a "fresh install" state.')
@ -26,7 +26,7 @@ class Command(NoArgsCommand):
dest='load_initial_data', default=True, dest='load_initial_data', default=True,
help='Tells Django not to load any initial data after database synchronization.') help='Tells Django not to load any initial data after database synchronization.')
def handle_noargs(self, **options): def handle(self, **options):
database = options.get('database') database = options.get('database')
connection = connections[database] connection = connections[database]
verbosity = options.get('verbosity') verbosity = options.get('verbosity')

View File

@ -4,11 +4,11 @@ from collections import OrderedDict
import keyword import keyword
import re import re
from django.core.management.base import NoArgsCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.db import connections, DEFAULT_DB_ALIAS from django.db import connections, DEFAULT_DB_ALIAS
class Command(NoArgsCommand): class Command(BaseCommand):
help = "Introspects the database tables in the given database and outputs a Django model module." help = "Introspects the database tables in the given database and outputs a Django model module."
requires_system_checks = False requires_system_checks = False
@ -20,7 +20,7 @@ class Command(NoArgsCommand):
default=DEFAULT_DB_ALIAS, help='Nominates a database to ' default=DEFAULT_DB_ALIAS, help='Nominates a database to '
'introspect. Defaults to using the "default" database.') 'introspect. Defaults to using the "default" database.')
def handle_noargs(self, **options): def handle(self, **options):
try: try:
for line in self.handle_inspection(options): for line in self.handle_inspection(options):
self.stdout.write("%s\n" % line) self.stdout.write("%s\n" % line)

View File

@ -9,7 +9,7 @@ import sys
from itertools import dropwhile from itertools import dropwhile
import django import django
from django.core.management.base import CommandError, NoArgsCommand from django.core.management.base import CommandError, BaseCommand
from django.core.management.utils import (handle_extensions, find_command, from django.core.management.utils import (handle_extensions, find_command,
popen_wrapper) popen_wrapper)
from django.utils.encoding import force_str from django.utils.encoding import force_str
@ -162,7 +162,7 @@ def write_pot_file(potfile, msgs):
fp.write(msgs) fp.write(msgs)
class Command(NoArgsCommand): class Command(BaseCommand):
help = ("Runs over the entire source tree of the current directory and " help = ("Runs over the entire source tree of the current directory and "
"pulls out all strings marked for translation. It creates (or updates) a message " "pulls out all strings marked for translation. It creates (or updates) a message "
"file in the conf/locale (in the django tree) or locale (for projects and " "file in the conf/locale (in the django tree) or locale (for projects and "
@ -210,7 +210,7 @@ class Command(NoArgsCommand):
parser.add_argument('--keep-pot', action='store_true', dest='keep_pot', parser.add_argument('--keep-pot', action='store_true', dest='keep_pot',
default=False, help="Keep .pot file after making messages. Useful when debugging.") default=False, help="Keep .pot file after making messages. Useful when debugging.")
def handle_noargs(self, *args, **options): def handle(self, *args, **options):
locale = options.get('locale') locale = options.get('locale')
exclude = options.get('exclude') exclude = options.get('exclude')
self.domain = options.get('domain') self.domain = options.get('domain')

View File

@ -1,9 +1,9 @@
import os import os
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
class Command(NoArgsCommand): class Command(BaseCommand):
help = "Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available." help = "Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available."
requires_system_checks = False requires_system_checks = False
shells = ['ipython', 'bpython'] shells = ['ipython', 'bpython']
@ -60,7 +60,7 @@ class Command(NoArgsCommand):
pass pass
raise ImportError raise ImportError
def handle_noargs(self, **options): def handle(self, **options):
try: try:
if options['plain']: if options['plain']:
# Don't bother loading IPython, because the user wants plain Python. # Don't bother loading IPython, because the user wants plain Python.

View File

@ -1,11 +1,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
from django.core.management.sql import sql_flush from django.core.management.sql import sql_flush
from django.db import connections, DEFAULT_DB_ALIAS from django.db import connections, DEFAULT_DB_ALIAS
class Command(NoArgsCommand): class Command(BaseCommand):
help = "Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed." help = "Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed."
output_transaction = True output_transaction = True
@ -16,5 +16,5 @@ class Command(NoArgsCommand):
help='Nominates a database to print the SQL for. Defaults to the ' help='Nominates a database to print the SQL for. Defaults to the '
'"default" database.') '"default" database.')
def handle_noargs(self, **options): def handle(self, **options):
return '\n'.join(sql_flush(self.style, connections[options['database']], only_django=True)) return '\n'.join(sql_flush(self.style, connections[options['database']], only_django=True))

View File

@ -4,12 +4,12 @@ from django.apps import apps
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.db import DEFAULT_DB_ALIAS from django.db import DEFAULT_DB_ALIAS
from django.core.management import call_command from django.core.management import call_command
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
from django.utils.deprecation import RemovedInDjango19Warning from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.six.moves import input from django.utils.six.moves import input
class Command(NoArgsCommand): class Command(BaseCommand):
help = "Deprecated - use 'migrate' instead." help = "Deprecated - use 'migrate' instead."
def add_arguments(self, parser): def add_arguments(self, parser):
@ -20,7 +20,7 @@ class Command(NoArgsCommand):
parser.add_argument('--database', default=DEFAULT_DB_ALIAS, parser.add_argument('--database', default=DEFAULT_DB_ALIAS,
help='Nominates a database to synchronize. Defaults to the "default" database.') help='Nominates a database to synchronize. Defaults to the "default" database.')
def handle_noargs(self, **options): def handle(self, **options):
warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning) warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)
call_command("migrate", **options) call_command("migrate", **options)

View File

@ -10,7 +10,7 @@ from django.utils.deprecation import RemovedInDjango19Warning
class Command(CheckCommand): class Command(CheckCommand):
help = 'Deprecated. Use "check" command instead. ' + CheckCommand.help help = 'Deprecated. Use "check" command instead. ' + CheckCommand.help
def handle_noargs(self, **options): def handle(self, **options):
warnings.warn('"validate" has been deprecated in favor of "check".', warnings.warn('"validate" has been deprecated in favor of "check".',
RemovedInDjango19Warning) RemovedInDjango19Warning)
super(Command, self).handle_noargs(**options) super(Command, self).handle(**options)

View File

@ -152,8 +152,8 @@ require a system-neutral string language (for which we use 'en-us').
If, for some reason, your custom management command needs to use a fixed locale If, for some reason, your custom management command needs to use a fixed locale
different from 'en-us', you should manually activate and deactivate it in your different from 'en-us', you should manually activate and deactivate it in your
:meth:`~BaseCommand.handle` or :meth:`~NoArgsCommand.handle_noargs` method using :meth:`~BaseCommand.handle` method using the functions provided by the I18N
the functions provided by the I18N support code: support code:
.. code-block:: python .. code-block:: python
@ -431,6 +431,10 @@ Rather than implementing :meth:`~BaseCommand.handle`, subclasses must implement
.. class:: NoArgsCommand .. class:: NoArgsCommand
.. deprecated:: 1.8
Use :class:`BaseCommand` instead, which takes no arguments by default.
A command which takes no arguments on the command line. A command which takes no arguments on the command line.
Rather than implementing :meth:`~BaseCommand.handle`, subclasses must implement Rather than implementing :meth:`~BaseCommand.handle`, subclasses must implement

View File

@ -38,6 +38,10 @@ about each item can often be found in the release notes of two versions prior.
* Support for :py:mod:`optparse` will be dropped for custom management commands * Support for :py:mod:`optparse` will be dropped for custom management commands
(replaced by :py:mod:`argparse`). (replaced by :py:mod:`argparse`).
* The class :class:`~django.core.management.NoArgsCommand` will be removed. Use
:class:`~django.core.management.BaseCommand` instead, which takes no arguments
by default.
.. _deprecation-removed-in-1.9: .. _deprecation-removed-in-1.9:
1.9 1.9

View File

@ -471,3 +471,10 @@ to add custom arguments to commands has changed: instead of extending the
:meth:`~django.core.management.BaseCommand.add_arguments` method and add :meth:`~django.core.management.BaseCommand.add_arguments` method and add
arguments through ``argparse.add_argument()``. See arguments through ``argparse.add_argument()``. See
:ref:`this example <custom-commands-options>` for more details. :ref:`this example <custom-commands-options>` for more details.
``django.core.management.NoArgsCommand``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The class :class:`~django.core.management.NoArgsCommand` is now deprecated and
will be removed in Django 2.0. Use :class:`~django.core.management.BaseCommand`
instead, which takes no arguments by default.

View File

@ -1,7 +1,7 @@
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
class Command(NoArgsCommand): class Command(BaseCommand):
def handle_noargs(self, **options): def handle(self, **options):
self.stdout.write('complex_app') self.stdout.write('complex_app')

View File

@ -1,9 +1,9 @@
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
class Command(NoArgsCommand): class Command(BaseCommand):
help = "Test color output" help = "Test color output"
requires_system_checks = False requires_system_checks = False
def handle_noargs(self, **options): def handle(self, **options):
return self.style.SQL_KEYWORD('BEGIN') return self.style.SQL_KEYWORD('BEGIN')

View File

@ -1,9 +1,9 @@
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
class Command(NoArgsCommand): class Command(BaseCommand):
help = "Test No-args commands" help = "Test No-args commands"
requires_system_checks = False requires_system_checks = False
def handle_noargs(self, **options): def handle(self, **options):
print('EXECUTE:NoArgsCommand options=%s' % sorted(options.items())) print('EXECUTE: noargs_command options=%s' % sorted(options.items()))

View File

@ -1,11 +1,11 @@
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
class InvalidCommand(NoArgsCommand): class InvalidCommand(BaseCommand):
help = ("Test raising an error if both requires_system_checks " help = ("Test raising an error if both requires_system_checks "
"and requires_model_validation are defined.") "and requires_model_validation are defined.")
requires_system_checks = True requires_system_checks = True
requires_model_validation = True requires_model_validation = True
def handle_noargs(self, **options): def handle(self, **options):
pass pass

View File

@ -1,7 +1,7 @@
from django.core.management.base import NoArgsCommand from django.core.management.base import BaseCommand
class Command(NoArgsCommand): class Command(BaseCommand):
def handle_noargs(self, **options): def handle(self, **options):
self.stdout.write('simple_app') self.stdout.write('simple_app')

View File

@ -282,14 +282,14 @@ class DjangoAdminDefaultSettings(AdminScriptTestCase):
args = ['noargs_command', '--settings=test_project.settings'] args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_django_admin(args) out, err = self.run_django_admin(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_environment(self): def test_custom_command_with_environment(self):
"default: django-admin can execute user commands if settings are provided in environment" "default: django-admin can execute user commands if settings are provided in environment"
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_django_admin(args, 'test_project.settings') out, err = self.run_django_admin(args, 'test_project.settings')
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase): class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
@ -349,14 +349,14 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
args = ['noargs_command', '--settings=test_project.settings'] args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_django_admin(args) out, err = self.run_django_admin(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_environment(self): def test_custom_command_with_environment(self):
"fulldefault: django-admin can execute user commands if settings are provided in environment" "fulldefault: django-admin can execute user commands if settings are provided in environment"
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_django_admin(args, 'test_project.settings') out, err = self.run_django_admin(args, 'test_project.settings')
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
class DjangoAdminMinimalSettings(AdminScriptTestCase): class DjangoAdminMinimalSettings(AdminScriptTestCase):
@ -483,14 +483,14 @@ class DjangoAdminAlternateSettings(AdminScriptTestCase):
args = ['noargs_command', '--settings=test_project.alternate_settings'] args = ['noargs_command', '--settings=test_project.alternate_settings']
out, err = self.run_django_admin(args) out, err = self.run_django_admin(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_environment(self): def test_custom_command_with_environment(self):
"alternate: django-admin can execute user commands if settings are provided in environment" "alternate: django-admin can execute user commands if settings are provided in environment"
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_django_admin(args, 'test_project.alternate_settings') out, err = self.run_django_admin(args, 'test_project.alternate_settings')
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
class DjangoAdminMultipleSettings(AdminScriptTestCase): class DjangoAdminMultipleSettings(AdminScriptTestCase):
@ -553,14 +553,14 @@ class DjangoAdminMultipleSettings(AdminScriptTestCase):
args = ['noargs_command', '--settings=test_project.alternate_settings'] args = ['noargs_command', '--settings=test_project.alternate_settings']
out, err = self.run_django_admin(args) out, err = self.run_django_admin(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_environment(self): def test_custom_command_with_environment(self):
"alternate: django-admin can execute user commands if settings are provided in environment" "alternate: django-admin can execute user commands if settings are provided in environment"
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_django_admin(args, 'test_project.alternate_settings') out, err = self.run_django_admin(args, 'test_project.alternate_settings')
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
class DjangoAdminSettingsDirectory(AdminScriptTestCase): class DjangoAdminSettingsDirectory(AdminScriptTestCase):
@ -718,21 +718,21 @@ class ManageDefaultSettings(AdminScriptTestCase):
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_settings(self): def test_custom_command_with_settings(self):
"default: manage.py can execute user commands when settings are provided as argument" "default: manage.py can execute user commands when settings are provided as argument"
args = ['noargs_command', '--settings=test_project.settings'] args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_environment(self): def test_custom_command_with_environment(self):
"default: manage.py can execute user commands when settings are provided in environment" "default: manage.py can execute user commands when settings are provided in environment"
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_manage(args, 'test_project.settings') out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
class ManageFullPathDefaultSettings(AdminScriptTestCase): class ManageFullPathDefaultSettings(AdminScriptTestCase):
@ -785,21 +785,21 @@ class ManageFullPathDefaultSettings(AdminScriptTestCase):
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_settings(self): def test_custom_command_with_settings(self):
"fulldefault: manage.py can execute user commands when settings are provided as argument" "fulldefault: manage.py can execute user commands when settings are provided as argument"
args = ['noargs_command', '--settings=test_project.settings'] args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_environment(self): def test_custom_command_with_environment(self):
"fulldefault: manage.py can execute user commands when settings are provided in environment" "fulldefault: manage.py can execute user commands when settings are provided in environment"
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_manage(args, 'test_project.settings') out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
class ManageMinimalSettings(AdminScriptTestCase): class ManageMinimalSettings(AdminScriptTestCase):
@ -929,21 +929,21 @@ class ManageAlternateSettings(AdminScriptTestCase):
"alternate: manage.py can execute user commands if settings are provided as argument" "alternate: manage.py can execute user commands if settings are provided as argument"
args = ['noargs_command', '--settings=alternate_settings'] args = ['noargs_command', '--settings=alternate_settings']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('no_color', False), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', False), ('verbosity', 1)]") self.assertOutput(out, "EXECUTE: noargs_command options=[('no_color', False), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', False), ('verbosity', 1)]")
self.assertNoOutput(err) self.assertNoOutput(err)
def test_custom_command_with_environment(self): def test_custom_command_with_environment(self):
"alternate: manage.py can execute user commands if settings are provided in environment" "alternate: manage.py can execute user commands if settings are provided in environment"
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_manage(args, 'alternate_settings') out, err = self.run_manage(args, 'alternate_settings')
self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', False), ('verbosity', 1)]") self.assertOutput(out, "EXECUTE: noargs_command options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', False), ('verbosity', 1)]")
self.assertNoOutput(err) self.assertNoOutput(err)
def test_custom_command_output_color(self): def test_custom_command_output_color(self):
"alternate: manage.py output syntax color can be deactivated with the `--no-color` option" "alternate: manage.py output syntax color can be deactivated with the `--no-color` option"
args = ['noargs_command', '--no-color', '--settings=alternate_settings'] args = ['noargs_command', '--no-color', '--settings=alternate_settings']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('no_color', True), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', False), ('verbosity', 1)]") self.assertOutput(out, "EXECUTE: noargs_command options=[('no_color', True), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', False), ('verbosity', 1)]")
self.assertNoOutput(err) self.assertNoOutput(err)
@ -1008,14 +1008,14 @@ class ManageMultipleSettings(AdminScriptTestCase):
args = ['noargs_command', '--settings=alternate_settings'] args = ['noargs_command', '--settings=alternate_settings']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
def test_custom_command_with_environment(self): def test_custom_command_with_environment(self):
"multiple: manage.py can execute user commands if settings are provided in environment" "multiple: manage.py can execute user commands if settings are provided in environment"
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_manage(args, 'alternate_settings') out, err = self.run_manage(args, 'alternate_settings')
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand") self.assertOutput(out, "EXECUTE: noargs_command")
class ManageSettingsWithSettingsErrors(AdminScriptTestCase): class ManageSettingsWithSettingsErrors(AdminScriptTestCase):
@ -1496,7 +1496,7 @@ class CommandTypes(AdminScriptTestCase):
args = ['noargs_command'] args = ['noargs_command']
out, err = self.run_manage(args) out, err = self.run_manage(args)
self.assertNoOutput(err) self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', False), ('verbosity', 1)]") self.assertOutput(out, "EXECUTE: noargs_command options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', False), ('verbosity', 1)]")
def test_noargs_with_args(self): def test_noargs_with_args(self):
"NoArg Commands raise an error if an argument is provided" "NoArg Commands raise an error if an argument is provided"