mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[2.0.x] Fixed #28941 -- Fixed crash in testserver command startup.
Regression in2b09e4c88e. Backport ofe7b804c060from master
This commit is contained in:
		| @@ -27,6 +27,7 @@ class Command(BaseCommand): | |||||||
|     # Validation is called explicitly each time the server is reloaded. |     # Validation is called explicitly each time the server is reloaded. | ||||||
|     requires_system_checks = False |     requires_system_checks = False | ||||||
|     leave_locale_alone = True |     leave_locale_alone = True | ||||||
|  |     stealth_options = ('shutdown_message',) | ||||||
|  |  | ||||||
|     default_addr = '127.0.0.1' |     default_addr = '127.0.0.1' | ||||||
|     default_addr_ipv6 = '::1' |     default_addr_ipv6 = '::1' | ||||||
|   | |||||||
| @@ -29,3 +29,5 @@ Bugfixes | |||||||
|  |  | ||||||
| * Fixed a regression on SQLite where ``DecimalField`` returned a result with | * Fixed a regression on SQLite where ``DecimalField`` returned a result with | ||||||
|   trailing zeros in the fractional part truncated (:ticket:`28915`). |   trailing zeros in the fractional part truncated (:ticket:`28915`). | ||||||
|  |  | ||||||
|  | * Fixed crash in the ``testserver`` command startup (:ticket:`28941`). | ||||||
|   | |||||||
| @@ -21,7 +21,9 @@ from django.conf import settings | |||||||
| from django.core.management import ( | from django.core.management import ( | ||||||
|     BaseCommand, CommandError, call_command, color, |     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.db.migrations.recorder import MigrationRecorder | ||||||
| from django.test import ( | from django.test import ( | ||||||
|     LiveServerTestCase, SimpleTestCase, TestCase, override_settings, |     LiveServerTestCase, SimpleTestCase, TestCase, override_settings, | ||||||
| @@ -1406,6 +1408,31 @@ class ManageTestserver(AdminScriptTestCase): | |||||||
|             skip_checks=True, interactive=True, |             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 | # COMMAND PROCESSING TESTS | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user