Ticket #5430: docs-runtests.diff

File docs-runtests.diff, 1.9 KB (added by Antti Kaihola, 12 years ago)

additional documentation for running Django's own unit tests

  • docs/contributing.txt

     
    652652Yes, the unit tests need a settings module, but only for database connection
    653653info, with the ``DATABASE_ENGINE`` setting. You will also need a ``ROOT_URLCONF``
    654654setting (its value is ignored; it just needs to be present) and a ``SITE_ID``
    655 setting (any non-zero integer value will do) in order for all the tests to pass.
     655setting (any non-zero integer value will do) in order for all the
     656tests to pass.
    656657
    657 The unit tests will not touch your existing databases; they create a new
    658 database, called ``django_test_db``, which is deleted when the tests are
     658If you use the ``sqlite3`` database engine, no further settings are needed and a
     659temporary database will be created in memory when running the tests.
     660
     661For other backends, the ``DATABASE_USER`` setting needs to specify an existing
     662user account for the database engine. The ``DATABASE_NAME`` setting must be the
     663name of an existing database to which the given user has permission to connect.
     664The unit tests will not touch that database; they create a new database which
     665has the same name prefixed with ``test_``, and it is deleted when the tests are
    659666finished. This means your user account needs permission to execute ``CREATE
    660667DATABASE``.
    661668
     669To run a subset of the unit tests, append the names of the test modules to the
     670``runtests.py`` command line. See the list of directories in
     671``tests/modeltests`` and ``tests/regressiontests`` for module names.
     672
     673As an example, if Django is not in your ``PYTHONPATH``, you placed
     674``settings.py`` in the ``tests/`` directory, and you'd like to only run tests
     675for generic relations and internationalization, type::
     676
     677    PYTHONPATH=.. ./runtests.py --settings=settings generic_relations i18n
     678
    662679Requesting features
    663680===================
    664681
Back to Top