diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py index d22f76054a..fd49817f81 100644 --- a/django/core/management/commands/runserver.py +++ b/django/core/management/commands/runserver.py @@ -27,6 +27,7 @@ class Command(BaseCommand): # Validation is called explicitly each time the server is reloaded. requires_system_checks = False leave_locale_alone = True + stealth_options = ('shutdown_message',) default_addr = '127.0.0.1' default_addr_ipv6 = '::1' diff --git a/docs/releases/2.0.1.txt b/docs/releases/2.0.1.txt index f763691464..9d2163b2b6 100644 --- a/docs/releases/2.0.1.txt +++ b/docs/releases/2.0.1.txt @@ -29,3 +29,5 @@ Bugfixes * Fixed a regression on SQLite where ``DecimalField`` returned a result with trailing zeros in the fractional part truncated (:ticket:`28915`). + +* Fixed crash in the ``testserver`` command startup (:ticket:`28941`). diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 1670af86fb..3ee417b6d0 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -21,7 +21,9 @@ from django.conf import settings from django.core.management import ( BaseCommand, CommandError, call_command, color, ) -from django.db import ConnectionHandler +from django.core.management.commands.loaddata import Command as LoaddataCommand +from django.core.management.commands.runserver import Command as RunserverCommand +from django.db import ConnectionHandler, connection from django.db.migrations.recorder import MigrationRecorder from django.test import ( LiveServerTestCase, SimpleTestCase, TestCase, override_settings, @@ -1416,6 +1418,31 @@ class ManageTestserver(AdminScriptTestCase): skip_checks=True, interactive=True, ) + @mock.patch('django.db.connection.creation.create_test_db', return_value='test_db') + @mock.patch.object(LoaddataCommand, 'handle', return_value='') + @mock.patch.object(RunserverCommand, 'handle', return_value='') + def test_params_to_runserver(self, mock_runserver_handle, mock_loaddata_handle, mock_create_test_db): + out = StringIO() + call_command('testserver', 'blah.json', stdout=out) + mock_runserver_handle.assert_called_with( + addrport='', + insecure_serving=False, + no_color=False, + pythonpath=None, + settings=None, + shutdown_message=( + "\nServer stopped.\nNote that the test database, 'test_db', " + "has not been deleted. You can explore it on your own." + ), + skip_checks=True, + traceback=False, + use_ipv6=False, + use_reloader=False, + use_static_handler=True, + use_threading=connection.features.test_db_allows_multiple_connections, + verbosity=1, + ) + ########################################################################## # COMMAND PROCESSING TESTS