| | 273 | The test database |
|---|
| | 274 | ----------------- |
|---|
| | 275 | |
|---|
| | 276 | Tests that require a database (namely, model tests) will not use |
|---|
| | 277 | your "real" (production) database. A separate, blank database is created |
|---|
| | 278 | for the tests. |
|---|
| | 279 | |
|---|
| | 280 | Regardless of whether the tests pass or fail, the test database is destroyed |
|---|
| | 281 | when all the tests have been executed. |
|---|
| | 282 | |
|---|
| | 283 | By default this test database gets its name by prepending ``test_`` to the |
|---|
| | 284 | value of the ``DATABASE_NAME`` setting. When using the SQLite database engine |
|---|
| | 285 | the tests will by default use a memory resident database. If you want to use |
|---|
| | 286 | a different database name, specify the ``TEST_DATABASE_NAME`` setting. |
|---|
| | 287 | |
|---|
| | 288 | Aside from using a separate database, the test runner will otherwise use all of |
|---|
| | 289 | the same database settings you have in your settings file: ``DATABASE_ENGINE``, |
|---|
| | 290 | ``DATABASE_USER``, ``DATABASE_HOST``, etc. The test database is created by the |
|---|
| | 291 | user specified by ``DATABASE_USER``, so you'll need to make sure that the given |
|---|
| | 292 | user account has sufficient privileges to create a new database on the system. |
|---|
| | 293 | |
|---|
| | 294 | **New in Django development version:** For fine-grained control over the |
|---|
| | 295 | character encoding of your test database, use the ``TEST_DATABASE_CHARSET`` |
|---|
| | 296 | setting. If you're using MySQL, you can also use the ``TEST_DATABASE_COLLATION`` |
|---|
| | 297 | setting to control the particular collation used by the test database. See the |
|---|
| | 298 | settings_ documentation for details of these advanced settings. |
|---|
| | 299 | |
|---|
| | 300 | .. _settings: ../settings/ |
|---|
| | 301 | |
|---|
| 285 | | This tells you that the test runner is creating a test database -- a blank, |
|---|
| 286 | | from-scratch database that it will use for any tests that happen to require a |
|---|
| 287 | | database (namely, model tests). |
|---|
| 288 | | |
|---|
| 289 | | Don't worry -- the test runner will not touch your "real" (production) |
|---|
| 290 | | database. It creates a separate database purely for the tests. This test |
|---|
| 291 | | database gets its name by prepending ``test_`` to the value of the |
|---|
| 292 | | ``DATABASE_NAME`` setting. If you want to use a different name, specify the |
|---|
| 293 | | ``TEST_DATABASE_NAME`` setting. |
|---|
| 294 | | |
|---|
| 295 | | Aside from using a separate database, the test runner will otherwise use all of |
|---|
| 296 | | the same database settings you have in your settings file: ``DATABASE_ENGINE``, |
|---|
| 297 | | ``DATABASE_USER``, ``DATABASE_HOST``, etc. The test database is created by the |
|---|
| 298 | | user specified by ``DATABASE_USER``, so you'll need to make sure that the given |
|---|
| 299 | | user account has sufficient privileges to create a new database on the system. |
|---|
| 300 | | |
|---|
| 301 | | **New in Django development version:** For fine-grained control over the |
|---|
| 302 | | character encoding of your test database, use the ``TEST_DATABASE_CHARSET`` |
|---|
| 303 | | setting. If you're using MySQL, you can also use the ``TEST_DATABASE_COLLATION`` |
|---|
| 304 | | setting to control the particular collation used by the test database. See the |
|---|
| 305 | | settings_ documentation for details of these advanced settings. |
|---|
| 306 | | |
|---|
| 307 | | .. _settings: ../settings/ |
|---|
| | 315 | This tells you that the test runner is creating a test database, as described |
|---|
| | 316 | in the previous section. |
|---|