Fixed #22835 -- Deprecated NoArgsCommand.
This commit is contained in:
parent
63670a474c
commit
9996158db4
|
@ -1,13 +1,13 @@
|
|||
from importlib import import_module
|
||||
|
||||
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)."
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, **options):
|
||||
engine = import_module(settings.SESSION_ENGINE)
|
||||
try:
|
||||
engine.SessionStore.clear_expired()
|
||||
|
|
|
@ -4,7 +4,8 @@ import os
|
|||
from collections import OrderedDict
|
||||
|
||||
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.six.moves import input
|
||||
|
||||
|
@ -12,7 +13,7 @@ from django.contrib.staticfiles.finders import get_finders
|
|||
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
|
||||
locations to the settings.STATIC_ROOT.
|
||||
|
@ -21,12 +22,13 @@ class Command(NoArgsCommand):
|
|||
requires_system_checks = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NoArgsCommand, self).__init__(*args, **kwargs)
|
||||
super(BaseCommand, self).__init__(*args, **kwargs)
|
||||
self.copied_files = []
|
||||
self.symlinked_files = []
|
||||
self.unmodified_files = []
|
||||
self.post_processed_files = []
|
||||
self.storage = staticfiles_storage
|
||||
self.style = no_style()
|
||||
try:
|
||||
self.storage.path('')
|
||||
except NotImplementedError:
|
||||
|
@ -79,7 +81,7 @@ class Command(NoArgsCommand):
|
|||
"""
|
||||
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:
|
||||
raise CommandError("Can't symlink to a remote destination.")
|
||||
|
@ -130,7 +132,7 @@ class Command(NoArgsCommand):
|
|||
'post_processed': self.post_processed_files,
|
||||
}
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, **options):
|
||||
self.set_options(**options)
|
||||
|
||||
message = ['\n']
|
||||
|
|
|
@ -603,6 +603,14 @@ class NoArgsCommand(BaseCommand):
|
|||
"""
|
||||
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):
|
||||
if args:
|
||||
raise CommandError("Command doesn't accept any arguments")
|
||||
|
|
|
@ -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('_')):
|
||||
|
@ -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))
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
help = """Displays differences between the current settings.py and Django's
|
||||
default settings. Settings that don't appear in the defaults are
|
||||
followed by "###"."""
|
||||
|
@ -18,7 +18,7 @@ class Command(NoArgsCommand):
|
|||
help='Display all settings, regardless of their value. '
|
||||
'Default values are prefixed by "###".')
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, **options):
|
||||
# Inspired by Postfix's "postconf -n".
|
||||
from django.conf import settings, global_settings
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ from importlib import import_module
|
|||
from django.apps import apps
|
||||
from django.db import connections, router, transaction, DEFAULT_DB_ALIAS
|
||||
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.sql import sql_flush, emit_post_migrate_signal
|
||||
from django.utils.six.moves import input
|
||||
from django.utils import six
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
help = ('Removes ALL DATA from the database, including data added during '
|
||||
'migrations. Unmigrated apps will also have their initial_data '
|
||||
'fixture reloaded. Does not achieve a "fresh install" state.')
|
||||
|
@ -26,7 +26,7 @@ class Command(NoArgsCommand):
|
|||
dest='load_initial_data', default=True,
|
||||
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')
|
||||
connection = connections[database]
|
||||
verbosity = options.get('verbosity')
|
||||
|
|
|
@ -4,11 +4,11 @@ from collections import OrderedDict
|
|||
import keyword
|
||||
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
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
help = "Introspects the database tables in the given database and outputs a Django model module."
|
||||
|
||||
requires_system_checks = False
|
||||
|
@ -20,7 +20,7 @@ class Command(NoArgsCommand):
|
|||
default=DEFAULT_DB_ALIAS, help='Nominates a database to '
|
||||
'introspect. Defaults to using the "default" database.')
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, **options):
|
||||
try:
|
||||
for line in self.handle_inspection(options):
|
||||
self.stdout.write("%s\n" % line)
|
||||
|
|
|
@ -9,7 +9,7 @@ import sys
|
|||
from itertools import dropwhile
|
||||
|
||||
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,
|
||||
popen_wrapper)
|
||||
from django.utils.encoding import force_str
|
||||
|
@ -162,7 +162,7 @@ def write_pot_file(potfile, msgs):
|
|||
fp.write(msgs)
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
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 "
|
||||
"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',
|
||||
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')
|
||||
exclude = options.get('exclude')
|
||||
self.domain = options.get('domain')
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
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."
|
||||
requires_system_checks = False
|
||||
shells = ['ipython', 'bpython']
|
||||
|
@ -60,7 +60,7 @@ class Command(NoArgsCommand):
|
|||
pass
|
||||
raise ImportError
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, **options):
|
||||
try:
|
||||
if options['plain']:
|
||||
# Don't bother loading IPython, because the user wants plain Python.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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.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."
|
||||
|
||||
output_transaction = True
|
||||
|
@ -16,5 +16,5 @@ class Command(NoArgsCommand):
|
|||
help='Nominates a database to print the SQL for. Defaults to the '
|
||||
'"default" database.')
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, **options):
|
||||
return '\n'.join(sql_flush(self.style, connections[options['database']], only_django=True))
|
||||
|
|
|
@ -4,12 +4,12 @@ from django.apps import apps
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.db import DEFAULT_DB_ALIAS
|
||||
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.six.moves import input
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
class Command(BaseCommand):
|
||||
help = "Deprecated - use 'migrate' instead."
|
||||
|
||||
def add_arguments(self, parser):
|
||||
|
@ -20,7 +20,7 @@ class Command(NoArgsCommand):
|
|||
parser.add_argument('--database', default=DEFAULT_DB_ALIAS,
|
||||
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)
|
||||
call_command("migrate", **options)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from django.utils.deprecation import RemovedInDjango19Warning
|
|||
class Command(CheckCommand):
|
||||
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".',
|
||||
RemovedInDjango19Warning)
|
||||
super(Command, self).handle_noargs(**options)
|
||||
super(Command, self).handle(**options)
|
||||
|
|
|
@ -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
|
||||
different from 'en-us', you should manually activate and deactivate it in your
|
||||
:meth:`~BaseCommand.handle` or :meth:`~NoArgsCommand.handle_noargs` method using
|
||||
the functions provided by the I18N support code:
|
||||
:meth:`~BaseCommand.handle` method using the functions provided by the I18N
|
||||
support code:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -431,6 +431,10 @@ Rather than implementing :meth:`~BaseCommand.handle`, subclasses must implement
|
|||
|
||||
.. 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.
|
||||
|
||||
Rather than implementing :meth:`~BaseCommand.handle`, subclasses must implement
|
||||
|
|
|
@ -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
|
||||
(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:
|
||||
|
||||
1.9
|
||||
|
|
|
@ -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
|
||||
arguments through ``argparse.add_argument()``. See
|
||||
: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.
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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"
|
||||
requires_system_checks = False
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, **options):
|
||||
return self.style.SQL_KEYWORD('BEGIN')
|
||||
|
|
|
@ -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"
|
||||
requires_system_checks = False
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
print('EXECUTE:NoArgsCommand options=%s' % sorted(options.items()))
|
||||
def handle(self, **options):
|
||||
print('EXECUTE: noargs_command options=%s' % sorted(options.items()))
|
||||
|
|
|
@ -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 "
|
||||
"and requires_model_validation are defined.")
|
||||
requires_system_checks = True
|
||||
requires_model_validation = True
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
def handle(self, **options):
|
||||
pass
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -282,14 +282,14 @@ class DjangoAdminDefaultSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command', '--settings=test_project.settings']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_environment(self):
|
||||
"default: django-admin can execute user commands if settings are provided in environment"
|
||||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args, 'test_project.settings')
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
|
||||
class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
|
||||
|
@ -349,14 +349,14 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command', '--settings=test_project.settings']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_environment(self):
|
||||
"fulldefault: django-admin can execute user commands if settings are provided in environment"
|
||||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args, 'test_project.settings')
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
|
||||
class DjangoAdminMinimalSettings(AdminScriptTestCase):
|
||||
|
@ -483,14 +483,14 @@ class DjangoAdminAlternateSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command', '--settings=test_project.alternate_settings']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_environment(self):
|
||||
"alternate: django-admin can execute user commands if settings are provided in environment"
|
||||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args, 'test_project.alternate_settings')
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
|
||||
class DjangoAdminMultipleSettings(AdminScriptTestCase):
|
||||
|
@ -553,14 +553,14 @@ class DjangoAdminMultipleSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command', '--settings=test_project.alternate_settings']
|
||||
out, err = self.run_django_admin(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_environment(self):
|
||||
"alternate: django-admin can execute user commands if settings are provided in environment"
|
||||
args = ['noargs_command']
|
||||
out, err = self.run_django_admin(args, 'test_project.alternate_settings')
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
|
||||
class DjangoAdminSettingsDirectory(AdminScriptTestCase):
|
||||
|
@ -718,21 +718,21 @@ class ManageDefaultSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_manage(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_settings(self):
|
||||
"default: manage.py can execute user commands when settings are provided as argument"
|
||||
args = ['noargs_command', '--settings=test_project.settings']
|
||||
out, err = self.run_manage(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_environment(self):
|
||||
"default: manage.py can execute user commands when settings are provided in environment"
|
||||
args = ['noargs_command']
|
||||
out, err = self.run_manage(args, 'test_project.settings')
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
|
||||
class ManageFullPathDefaultSettings(AdminScriptTestCase):
|
||||
|
@ -785,21 +785,21 @@ class ManageFullPathDefaultSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_manage(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_settings(self):
|
||||
"fulldefault: manage.py can execute user commands when settings are provided as argument"
|
||||
args = ['noargs_command', '--settings=test_project.settings']
|
||||
out, err = self.run_manage(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_environment(self):
|
||||
"fulldefault: manage.py can execute user commands when settings are provided in environment"
|
||||
args = ['noargs_command']
|
||||
out, err = self.run_manage(args, 'test_project.settings')
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
|
||||
class ManageMinimalSettings(AdminScriptTestCase):
|
||||
|
@ -929,21 +929,21 @@ class ManageAlternateSettings(AdminScriptTestCase):
|
|||
"alternate: manage.py can execute user commands if settings are provided as argument"
|
||||
args = ['noargs_command', '--settings=alternate_settings']
|
||||
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)
|
||||
|
||||
def test_custom_command_with_environment(self):
|
||||
"alternate: manage.py can execute user commands if settings are provided in environment"
|
||||
args = ['noargs_command']
|
||||
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)
|
||||
|
||||
def test_custom_command_output_color(self):
|
||||
"alternate: manage.py output syntax color can be deactivated with the `--no-color` option"
|
||||
args = ['noargs_command', '--no-color', '--settings=alternate_settings']
|
||||
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)
|
||||
|
||||
|
||||
|
@ -1008,14 +1008,14 @@ class ManageMultipleSettings(AdminScriptTestCase):
|
|||
args = ['noargs_command', '--settings=alternate_settings']
|
||||
out, err = self.run_manage(args)
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
def test_custom_command_with_environment(self):
|
||||
"multiple: manage.py can execute user commands if settings are provided in environment"
|
||||
args = ['noargs_command']
|
||||
out, err = self.run_manage(args, 'alternate_settings')
|
||||
self.assertNoOutput(err)
|
||||
self.assertOutput(out, "EXECUTE:NoArgsCommand")
|
||||
self.assertOutput(out, "EXECUTE: noargs_command")
|
||||
|
||||
|
||||
class ManageSettingsWithSettingsErrors(AdminScriptTestCase):
|
||||
|
@ -1496,7 +1496,7 @@ class CommandTypes(AdminScriptTestCase):
|
|||
args = ['noargs_command']
|
||||
out, err = self.run_manage(args)
|
||||
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):
|
||||
"NoArg Commands raise an error if an argument is provided"
|
||||
|
|
Loading…
Reference in New Issue