Code

Ticket #6298: test_settings.diff

File test_settings.diff, 5.1 KB (added by tobias, 5 years ago)

just one example file, plus doc updates

Line 
1diff -r 210d6b8a8b68 docs/internals/contributing.txt
2--- a/docs/internals/contributing.txt   Sun Dec 13 14:23:43 2009 -0500
3+++ b/docs/internals/contributing.txt   Sun Dec 13 18:00:05 2009 -0500
4@@ -768,14 +768,14 @@
5 Unit tests
6 ==========
7 
8-Django comes with a test suite of its own, in the ``tests`` directory of the
9+Django comes with a test suite of its own, in the ``tests/`` directory of the
10 Django tarball. It's our policy to make sure all tests pass at all times.
11 
12 The tests cover:
13 
14     * Models and the database API (``tests/modeltests/``).
15-    * Everything else in core Django code (``tests/regressiontests``)
16-    * Contrib apps (``django/contrib/<contribapp>/tests``, see below)
17+    * Everything else in core Django code (``tests/regressiontests/``)
18+    * Contrib apps (``django/contrib/<contribapp>/tests/``, see below)
19 
20 We appreciate any and all contributions to the test suite!
21 
22@@ -792,16 +792,28 @@
23 
24     ./runtests.py --settings=path.to.django.settings
25 
26-Yes, the unit tests need a settings module, but only for database connection
27-info, with the ``DATABASE_ENGINE`` setting.
28+If the copy of Django you want to test is not already in your ``PYTHONPATH``,
29+you can run the tests as follows:
30 
31-If you're using the ``sqlite3`` database backend, no further settings are
32-needed. A temporary database will be created in memory when running the tests.
33+.. code-block:: bash
34 
35-If you're using another backend:
36+    PYTHONPATH=.. ./runtests.py --settings=path.to.django.settings
37+   
38+By default, the Django test suite does not output informational or status
39+messages while it is running the tests.  To see feedback similar to that
40+printed when testing a Django project, add ``--verbosity=1`` (or ``-v 1``) to
41+the ``runtests.py`` command.
42 
43-    * Your :setting:`DATABASE_USER` setting needs to specify an existing user account
44-      for the database engine.
45+The unit tests need a stripped-down settings module that includes the database
46+connection settings.  There is an example settings file named
47+``test_settings.py.example`` in the ``tests/`` directory that you can copy
48+and modify to suite your local configuration.
49+
50+If you're using the ``sqlite3`` database backend, only the ``DATABASE_ENGINE``
51+setting is needed. A temporary database will be created in memory when running
52+the tests.
53+
54+If you're using another backend you will also need:
55 
56     * The :setting:`DATABASE_NAME` setting must be the name of an existing database to
57       which the given user has permission to connect. The unit tests will not
58@@ -810,11 +822,23 @@
59       deleted when the tests are finished. This means your user account needs
60       permission to execute ``CREATE DATABASE``.
61 
62+    * Unless your database supports ident authentication (and you have it
63+      enabled), your :setting:`DATABASE_USER` setting needs to specify an
64+      existing user account for the database engine.
65+
66 You will also need to ensure that your database uses UTF-8 as the default
67 character set. If your database server doesn't use UTF-8 as a default charset,
68 you will need to include a value for ``TEST_DATABASE_CHARSET`` in your settings
69 file.
70 
71+The different databases that Django supports behave differently in certain
72+situations, so it is recommended to run the test suite against as many
73+database backends as possible.  You may want to create a separate settings
74+file for each of the backends you test against.
75+
76+Test suite dependencies
77+~~~~~~~~~~~~~~~~~~~~~~~
78+
79 If you want to run the full suite of tests, you'll need to install a number of
80 dependencies:
81 
82diff -r 210d6b8a8b68 tests/test_settings.py.example
83--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
84+++ b/tests/test_settings.py.example    Sun Dec 13 18:00:05 2009 -0500
85@@ -0,0 +1,25 @@
86+# This is an example test settings file for use with the Django test suite.
87+#
88+# To use it, make a copy of this file without the '.example' suffix and fill
89+# in the necessary database settings below.  The Django test suite does not
90+# require additional configuration in the test settings file.
91+#
92+# The 'sqlite3' backend requires only the DATABASE_ENGINE setting (an in-
93+# memory database will be used).  All other backends will require a
94+# DATABASE_NAME and potentially authentication information.  See the
95+# following section in the docs for more information:
96+#
97+# http://docs.djangoproject.com/en/dev/internals/contributing/#unit-tests
98+#
99+# The different databases that Django supports behave differently in certain
100+# situations, so it is recommended to run the test suite against as many
101+# database backends as possible.  You may want to create a separate settings
102+# file for each of the backends you test against.
103+
104+DATABASE_ENGINE = ''           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
105+DATABASE_NAME = ''             # Or path to database file if using sqlite3 (optional).
106+DATABASE_USER = ''             # Not used with sqlite3.
107+DATABASE_PASSWORD = ''         # Not used with sqlite3.
108+DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
109+DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
110+