Ticket #6298: test_settings.diff
File test_settings.diff, 5.1 KB (added by , 15 years ago) |
---|
-
docs/internals/contributing.txt
diff -r 210d6b8a8b68 docs/internals/contributing.txt
a b 768 768 Unit tests 769 769 ========== 770 770 771 Django comes with a test suite of its own, in the ``tests `` directory of the771 Django comes with a test suite of its own, in the ``tests/`` directory of the 772 772 Django tarball. It's our policy to make sure all tests pass at all times. 773 773 774 774 The tests cover: 775 775 776 776 * 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) 779 779 780 780 We appreciate any and all contributions to the test suite! 781 781 … … 792 792 793 793 ./runtests.py --settings=path.to.django.settings 794 794 795 Yes, the unit tests need a settings module, but only for database connection 796 info, with the ``DATABASE_ENGINE`` setting. 795 If the copy of Django you want to test is not already in your ``PYTHONPATH``, 796 you can run the tests as follows: 797 797 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 800 799 801 If you're using another backend: 800 PYTHONPATH=.. ./runtests.py --settings=path.to.django.settings 801 802 By default, the Django test suite does not output informational or status 803 messages while it is running the tests. To see feedback similar to that 804 printed when testing a Django project, add ``--verbosity=1`` (or ``-v 1``) to 805 the ``runtests.py`` command. 802 806 803 * Your :setting:`DATABASE_USER` setting needs to specify an existing user account 804 for the database engine. 807 The unit tests need a stripped-down settings module that includes the database 808 connection settings. There is an example settings file named 809 ``test_settings.py.example`` in the ``tests/`` directory that you can copy 810 and modify to suite your local configuration. 811 812 If you're using the ``sqlite3`` database backend, only the ``DATABASE_ENGINE`` 813 setting is needed. A temporary database will be created in memory when running 814 the tests. 815 816 If you're using another backend you will also need: 805 817 806 818 * The :setting:`DATABASE_NAME` setting must be the name of an existing database to 807 819 which the given user has permission to connect. The unit tests will not … … 810 822 deleted when the tests are finished. This means your user account needs 811 823 permission to execute ``CREATE DATABASE``. 812 824 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 813 829 You will also need to ensure that your database uses UTF-8 as the default 814 830 character set. If your database server doesn't use UTF-8 as a default charset, 815 831 you will need to include a value for ``TEST_DATABASE_CHARSET`` in your settings 816 832 file. 817 833 834 The different databases that Django supports behave differently in certain 835 situations, so it is recommended to run the test suite against as many 836 database backends as possible. You may want to create a separate settings 837 file for each of the backends you test against. 838 839 Test suite dependencies 840 ~~~~~~~~~~~~~~~~~~~~~~~ 841 818 842 If you want to run the full suite of tests, you'll need to install a number of 819 843 dependencies: 820 844 -
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 19 DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 20 DATABASE_NAME = '' # Or path to database file if using sqlite3 (optional). 21 DATABASE_USER = '' # Not used with sqlite3. 22 DATABASE_PASSWORD = '' # Not used with sqlite3. 23 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. 24 DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. 25