Ticket #11635: testserver_backend.patch
File testserver_backend.patch, 3.3 KB (added by , 15 years ago) |
---|
-
django/test/utils.py
80 80 del mail.outbox 81 81 82 82 83 def get_runner(settings ):84 test_path = settings.TEST_RUNNER.split('.')83 def get_runner(settings, wanted_method='TEST_RUNNER'): 84 test_path = getattr(settings, wanted_method).split('.') 85 85 # Allow for Python 2.5 relative paths 86 86 if len(test_path) > 1: 87 87 test_module_name = '.'.join(test_path[:-1]) … … 90 90 test_module = __import__(test_module_name, {}, {}, test_path[-1]) 91 91 test_runner = getattr(test_module, test_path[-1]) 92 92 return test_runner 93 94 def get_create_test_db(settings): 95 # Wrapper to deal with the strange way Django's core create_test_db is 96 # created. There really must be a more elegant solution. 97 if settings.TESTSERVER_DATABASE_CREATOR == 'django.db.connection.creation.create_test_db': 98 from django.db import connection 99 return connection.creation.create_test_db 100 else: 101 return get_runner(settings, wanted_method='TESTSERVER_DATABASE_CREATOR') -
django/conf/global_settings.py
381 381 # The name of the method to use to invoke the test suite 382 382 TEST_RUNNER = 'django.test.simple.run_tests' 383 383 384 # The name of the method to create a test database for use with the 385 # testserver management command 386 TESTSERVER_DATABASE_CREATOR = 'django.db.connection.creation.create_test_db' 387 384 388 # The name of the database to use for testing purposes. 385 389 # If None, a name of 'test_' + DATABASE_NAME will be assumed 386 390 TEST_DATABASE_NAME = None -
django/core/management/commands/testserver.py
15 15 16 16 def handle(self, *fixture_labels, **options): 17 17 from django.core.management import call_command 18 from django.db import connection 18 from django.conf import settings 19 from django.test.utils import get_create_test_db 19 20 20 21 verbosity = int(options.get('verbosity', 1)) 21 22 addrport = options.get('addrport') 22 23 23 24 # Create a test database. 24 db_name = connection.creation.create_test_db(verbosity=verbosity) 25 create_test_db = get_create_test_db(settings) 26 db_name = create_test_db(verbosity=verbosity) 25 27 26 28 # Import the fixture data into the test database. 27 29 call_command('loaddata', *fixture_labels, **{'verbosity': verbosity}) -
docs/ref/settings.txt
1110 1110 1111 1111 .. _Testing Django Applications: ../testing/ 1112 1112 1113 .. setting:: TESTSERVER_DATABASE_CREATOR 1114 1115 TESTSERVER_DATABASE_CREATOR 1116 --------------------------- 1117 1118 Default: ``'django.db.connection.creation.create_test_db'`` 1119 1120 The name of the method to use to create the database used by the 1121 :ref:`testserver` management command. 1122 1113 1123 .. setting:: TIME_FORMAT 1114 1124 1115 1125 TIME_FORMAT