Fixed #32296 -- Added --skip-checks option to runserver command.

This commit is contained in:
Hasan Ramezani 2020-12-24 16:29:54 +01:00 committed by Mariusz Felisiak
parent e8b4f23115
commit 34aa4f1997
4 changed files with 38 additions and 4 deletions

View File

@ -51,6 +51,10 @@ class Command(BaseCommand):
'--noreload', action='store_false', dest='use_reloader',
help='Tells Django to NOT use the auto-reloader.',
)
parser.add_argument(
'--skip-checks', action='store_true',
help='Skip system checks.',
)
def execute(self, *args, **options):
if options['no_color']:
@ -114,8 +118,9 @@ class Command(BaseCommand):
shutdown_message = options.get('shutdown_message', '')
quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C'
self.stdout.write("Performing system checks...\n\n")
self.check(display_num_errors=True)
if not options['skip_checks']:
self.stdout.write('Performing system checks...\n\n')
self.check(display_num_errors=True)
# Need to check migrations here, so can't use the
# requires_migrations_check attribute.
self.check_migrations()

View File

@ -968,7 +968,8 @@ more robust change detection, and a reduction in power usage. Django supports
When you start the server, and each time you change Python code while the
server is running, the system check framework will check your entire Django
project for some common errors (see the :djadmin:`check` command). If any
errors are found, they will be printed to standard output.
errors are found, they will be printed to standard output. You can use the
``--skip-checks`` option to skip running system checks.
You can run as many concurrent servers as you want, as long as they're on
separate ports by executing ``django-admin runserver`` more than once.
@ -1006,6 +1007,10 @@ multithreaded by default.
Uses IPv6 for the development server. This changes the default IP address from
``127.0.0.1`` to ``::1``.
.. versionchanged:: 4.0
Support for the ``--skip-checks`` option was added.
Examples of using different ports and addresses
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -153,7 +153,8 @@ Logging
Management Commands
~~~~~~~~~~~~~~~~~~~
* ...
* The :djadmin:`runserver` management command now supports the
:option:`--skip-checks` option.
Migrations
~~~~~~~~~~

View File

@ -1313,6 +1313,29 @@ class ManageRunserver(SimpleTestCase):
# You have # ...
self.assertIn('unapplied migration(s)', self.output.getvalue())
@mock.patch('django.core.management.commands.runserver.run')
@mock.patch('django.core.management.base.BaseCommand.check_migrations')
@mock.patch('django.core.management.base.BaseCommand.check')
def test_skip_checks(self, mocked_check, *mocked_objects):
call_command(
'runserver',
use_reloader=False,
skip_checks=True,
stdout=self.output,
)
self.assertNotIn('Performing system checks...', self.output.getvalue())
mocked_check.assert_not_called()
self.output.truncate(0)
call_command(
'runserver',
use_reloader=False,
skip_checks=False,
stdout=self.output,
)
self.assertIn('Performing system checks...', self.output.getvalue())
mocked_check.assert_called()
class ManageRunserverMigrationWarning(TestCase):