Changeset 3706
- Timestamp:
- 09/01/06 08:33:26 (2 years ago)
- Files:
-
- django/trunk/django/conf/global_settings.py (modified) (1 diff)
- django/trunk/django/test/utils.py (modified) (1 diff)
- django/trunk/docs/settings.txt (modified) (1 diff)
- django/trunk/docs/testing.txt (modified) (3 diffs)
- django/trunk/tests/runtests.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/conf/global_settings.py
r3660 r3706 302 302 ########### 303 303 304 TEST_RUNNER='django.test.simple.run_tests' 304 # The name of the method to use to invoke the test suite 305 TEST_RUNNER = 'django.test.simple.run_tests' 306 307 # The name of the database to use for testing purposes. 308 # If None, a name of 'test_' + DATABASE_NAME will be assumed 309 TEST_DATABASE_NAME = None django/trunk/django/test/utils.py
r3689 r3706 22 22 TEST_DATABASE_NAME = ":memory:" 23 23 else: 24 TEST_DATABASE_NAME = TEST_DATABASE_PREFIX + settings.DATABASE_NAME 24 if settings.TEST_DATABASE_NAME: 25 TEST_DATABASE_NAME = settings.TEST_DATABASE_NAME 26 else: 27 TEST_DATABASE_NAME = TEST_DATABASE_PREFIX + settings.DATABASE_NAME 25 28 26 29 # Create the test database and connect to it. We need to autocommit django/trunk/docs/settings.txt
r3689 r3706 767 767 .. _Testing Django Applications: ../testing/ 768 768 769 TEST_DATABASE_NAME 770 ------------------ 771 772 **New in Django development version** 773 774 Default: ``None`` 775 776 The name of database to use when running the test suite. If a value of 777 ``None`` is specified, the test database will use the name ``'test_' + settings.DATABASE_NAME``. See `Testing Django Applications`_. 778 779 .. _Testing Django Applications: ../testing/ 780 769 781 TIME_FORMAT 770 782 ----------- django/trunk/docs/testing.txt
r3689 r3706 9 9 used to validate that code behaves as expected. When refactoring or 10 10 modifying code, tests serve as a guide to ensure that behavior hasn't 11 changed as a result of the refactor.11 changed unexpectedly as a result of the refactor. 12 12 13 13 Testing an web application is a complex task, as there are many … … 190 190 When you run your tests, you'll see a bunch of text flow by as the test 191 191 database is created and models are initialized. This test database is 192 created from scratch every time you run your tests. The test database 193 gets its name by prepending ``test_`` to the database name specified by 194 ``settings.DATABASE_NAME``; all other database settings will the same as 195 they would be for the project normally. 192 created from scratch every time you run your tests. 193 194 By default, the test database gets its name by prepending ``test_`` to 195 the database name specified by the ``DATABASE_NAME`` setting; all other 196 database settings will the same as they would be for the project normally. 197 If you wish to use a name other than the default for the test database, 198 you can use the ``TEST_DATABASE_NAME`` setting to provide a name. 196 199 197 200 Once the test database has been established, Django will run your tests. … … 266 269 tested. This is the same format returned by ``django.db.models.get_apps()`` 267 270 268 Verbosity determines the amount of debug information that will be269 provided to the console; '0' is no output, '1' is normal output,271 Verbosity determines the amount of notification and debug information that 272 will be printed to the console; '0' is no output, '1' is normal output, 270 273 and `2` is verbose output. 271 274 django/trunk/tests/runtests.py
r3661 r3706 6 6 MODEL_TESTS_DIR_NAME = 'modeltests' 7 7 REGRESSION_TESTS_DIR_NAME = 'regressiontests' 8 TEST_DATABASE_NAME = 'django_test_db' 8 9 9 10 MODEL_TEST_DIR = os.path.join(os.path.dirname(__file__), MODEL_TESTS_DIR_NAME) … … 72 73 from django.db.models.loading import get_apps, load_app 73 74 old_installed_apps = settings.INSTALLED_APPS 75 old_test_database_name = settings.TEST_DATABASE_NAME 74 76 77 settings.TEST_DATABASE_NAME = TEST_DATABASE_NAME 78 settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS 79 75 80 # load all the ALWAYS_INSTALLED_APPS 76 settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS77 81 get_apps() 78 82 … … 106 110 run_tests(test_models, verbosity, extra_tests=extra_tests) 107 111 108 # Restore the old INSTALLED_APPS setting112 # Restore the old settings 109 113 settings.INSTALLED_APPS = old_installed_apps 110 114 settings.TESTS_DATABASE_NAME = old_test_database_name 111 115 if __name__ == "__main__": 112 116 from optparse import OptionParser
