Ticket #6298: test_settings.diff

File test_settings.diff, 5.1 KB (added by Tobias McNulty, 15 years ago)

just one example file, plus doc updates

  • docs/internals/contributing.txt

    diff -r 210d6b8a8b68 docs/internals/contributing.txt
    a b  
    768768Unit tests
    769769==========
    770770
    771 Django comes with a test suite of its own, in the ``tests`` directory of the
     771Django comes with a test suite of its own, in the ``tests/`` directory of the
    772772Django tarball. It's our policy to make sure all tests pass at all times.
    773773
    774774The tests cover:
    775775
    776776    * Models and the database API (``tests/modeltests/``).
    777     * Everything else in core Django code (``tests/regressiontests``)
    778     * Contrib apps (``django/contrib/<contribapp>/tests``, see below)
     777    * Everything else in core Django code (``tests/regressiontests/``)
     778    * Contrib apps (``django/contrib/<contribapp>/tests/``, see below)
    779779
    780780We appreciate any and all contributions to the test suite!
    781781
     
    792792
    793793    ./runtests.py --settings=path.to.django.settings
    794794
    795 Yes, the unit tests need a settings module, but only for database connection
    796 info, with the ``DATABASE_ENGINE`` setting.
     795If the copy of Django you want to test is not already in your ``PYTHONPATH``,
     796you can run the tests as follows:
    797797
    798 If you're using the ``sqlite3`` database backend, no further settings are
    799 needed. A temporary database will be created in memory when running the tests.
     798.. code-block:: bash
    800799
    801 If you're using another backend:
     800    PYTHONPATH=.. ./runtests.py --settings=path.to.django.settings
     801   
     802By default, the Django test suite does not output informational or status
     803messages while it is running the tests.  To see feedback similar to that
     804printed when testing a Django project, add ``--verbosity=1`` (or ``-v 1``) to
     805the ``runtests.py`` command.
    802806
    803     * Your :setting:`DATABASE_USER` setting needs to specify an existing user account
    804       for the database engine.
     807The unit tests need a stripped-down settings module that includes the database
     808connection settings.  There is an example settings file named
     809``test_settings.py.example`` in the ``tests/`` directory that you can copy
     810and modify to suite your local configuration.
     811
     812If you're using the ``sqlite3`` database backend, only the ``DATABASE_ENGINE``
     813setting is needed. A temporary database will be created in memory when running
     814the tests.
     815
     816If you're using another backend you will also need:
    805817
    806818    * The :setting:`DATABASE_NAME` setting must be the name of an existing database to
    807819      which the given user has permission to connect. The unit tests will not
     
    810822      deleted when the tests are finished. This means your user account needs
    811823      permission to execute ``CREATE DATABASE``.
    812824
     825    * Unless your database supports ident authentication (and you have it
     826      enabled), your :setting:`DATABASE_USER` setting needs to specify an
     827      existing user account for the database engine.
     828
    813829You will also need to ensure that your database uses UTF-8 as the default
    814830character set. If your database server doesn't use UTF-8 as a default charset,
    815831you will need to include a value for ``TEST_DATABASE_CHARSET`` in your settings
    816832file.
    817833
     834The different databases that Django supports behave differently in certain
     835situations, so it is recommended to run the test suite against as many
     836database backends as possible.  You may want to create a separate settings
     837file for each of the backends you test against.
     838
     839Test suite dependencies
     840~~~~~~~~~~~~~~~~~~~~~~~
     841
    818842If you want to run the full suite of tests, you'll need to install a number of
    819843dependencies:
    820844
  • new file tests/test_settings.py.example

    diff -r 210d6b8a8b68 tests/test_settings.py.example
    - +  
     1# This is an example test settings file for use with the Django test suite.
     2#
     3# To use it, make a copy of this file without the '.example' suffix and fill
     4# in the necessary database settings below.  The Django test suite does not
     5# require additional configuration in the test settings file.
     6#
     7# The 'sqlite3' backend requires only the DATABASE_ENGINE setting (an in-
     8# memory database will be used).  All other backends will require a
     9# DATABASE_NAME and potentially authentication information.  See the
     10# following section in the docs for more information:
     11#
     12# http://docs.djangoproject.com/en/dev/internals/contributing/#unit-tests
     13#
     14# The different databases that Django supports behave differently in certain
     15# situations, so it is recommended to run the test suite against as many
     16# database backends as possible.  You may want to create a separate settings
     17# file for each of the backends you test against.
     18
     19DATABASE_ENGINE = ''           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
     20DATABASE_NAME = ''             # Or path to database file if using sqlite3 (optional).
     21DATABASE_USER = ''             # Not used with sqlite3.
     22DATABASE_PASSWORD = ''         # Not used with sqlite3.
     23DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
     24DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
     25
Back to Top