Django

Code

Changeset 6929

Show
Ignore:
Timestamp:
12/17/07 02:50:32 (1 year ago)
Author:
mtredinnick
Message:

Split up the documentation of the test database and the test output.

Refs #6134.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/testing.txt

    r6632 r6929  
    271271    $ ./manage.py test animals.AnimalTestCase.testFluffyAnimals 
    272272 
     273The test database 
     274----------------- 
     275 
     276Tests that require a database (namely, model tests) will not use 
     277your "real" (production) database. A separate, blank database is created 
     278for the tests. 
     279 
     280Regardless of whether the tests pass or fail, the test database is destroyed 
     281when all the tests have been executed. 
     282 
     283By default this test database gets its name by prepending ``test_`` to the 
     284value of the ``DATABASE_NAME`` setting. When using the SQLite database engine 
     285the tests will by default use a memory resident database. If you want to use 
     286a different database name, specify the ``TEST_DATABASE_NAME`` setting. 
     287 
     288Aside from using a separate database, the test runner will otherwise use all of 
     289the same database settings you have in your settings file: ``DATABASE_ENGINE``, 
     290``DATABASE_USER``, ``DATABASE_HOST``, etc. The test database is created by the 
     291user specified by ``DATABASE_USER``, so you'll need to make sure that the given 
     292user 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 
     295character encoding of your test database, use the ``TEST_DATABASE_CHARSET`` 
     296setting. If you're using MySQL, you can also use the ``TEST_DATABASE_COLLATION`` 
     297setting to control the particular collation used by the test database. See the 
     298settings_ documentation for details of these advanced settings. 
     299 
     300.. _settings: ../settings/ 
     301 
    273302Understanding the test output 
    274303----------------------------- 
    275304 
    276305When you run your tests, you'll see a number of messages as the test runner 
    277 prepares itself:: 
     306prepares itself. You can control the level of detail of these messages with the 
     307``verbosity`` option on the command line:: 
    278308 
    279309    Creating test database... 
     
    283313    No fixtures found. 
    284314 
    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/ 
     315This tells you that the test runner is creating a test database, as described 
     316in the previous section. 
    308317 
    309318Once the test database has been created, Django will run your tests. 
     
    350359need to test for success or failure at that level. 
    351360 
    352 Regardless of whether the tests pass or fail, the test database is destroyed when 
    353 all the tests have been executed. 
    354  
    355361Testing tools 
    356362=============