~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to docs/internals/contributing/writing-code/unit-tests.txt

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2013-11-07 15:33:49 UTC
  • mfrom: (1.3.12)
  • Revision ID: package-import@ubuntu.com-20131107153349-e31sc149l2szs3jb
Tags: 1.6-1
* New upstream version. Closes: #557474, #724637.
* python-django now also suggests the installation of ipython,
  bpython, python-django-doc, and libgdal1.
  Closes: #636511, #686333, #704203
* Set package maintainer to Debian Python Modules Team.
* Bump standards version to 3.9.5, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
The tests cover:
9
9
 
10
 
* Models and the database API (``tests/modeltests``),
11
 
* Everything else in core Django code (``tests/regressiontests``),
12
 
* :ref:`contrib-apps` (``django/contrib/<app>/tests`` or
13
 
  ``tests/regressiontests/<app>_...``).
 
10
* Models, the database API and everything else in core Django core (``tests/``),
 
11
* :ref:`contrib-apps` (``django/contrib/<app>/tests`` or ``tests/<app>_...``).
14
12
 
15
13
We appreciate any and all contributions to the test suite!
16
14
 
65
63
If you're using a backend that isn't SQLite, you will need to provide other
66
64
details for each database:
67
65
 
68
 
* The :setting:`USER` option for each of your databases needs to
69
 
  specify an existing user account for the database.
 
66
* The :setting:`USER` option needs to specify an existing user account
 
67
  for the database.
70
68
 
71
69
* The :setting:`PASSWORD` option needs to provide the password for
72
70
  the :setting:`USER` that has been specified.
99
97
 
100
98
    ./runtests.py --settings=path.to.settings generic_relations i18n
101
99
 
102
 
How do you find out the names of individual tests? Look in
103
 
``tests/modeltests`` and ``tests/regressiontests`` — each directory name
104
 
there is the name of a test. Contrib app names are also valid test names.
 
100
How do you find out the names of individual tests? Look in ``tests/`` — each
 
101
directory name there is the name of a test. Contrib app names are also valid
 
102
test names.
105
103
 
106
104
If you just want to run a particular class of tests, you can specify a list of
107
105
paths to individual test classes. For example, to run the ``TranslationTests``
109
107
 
110
108
.. code-block:: bash
111
109
 
112
 
    ./runtests.py --settings=path.to.settings i18n.TranslationTests
 
110
    ./runtests.py --settings=path.to.settings i18n.tests.TranslationTests
113
111
 
114
112
Going beyond that, you can specify an individual test method like this:
115
113
 
116
114
.. code-block:: bash
117
115
 
118
 
    ./runtests.py --settings=path.to.settings i18n.TranslationTests.test_lazy_objects
 
116
    ./runtests.py --settings=path.to.settings i18n.tests.TranslationTests.test_lazy_objects
119
117
 
120
118
Running the Selenium tests
121
119
~~~~~~~~~~~~~~~~~~~~~~~~~~
122
120
 
123
121
Some admin tests require Selenium 2, Firefox and Python >= 2.6 to work via a
124
122
real Web browser. To allow those tests to run and not be skipped, you must
125
 
install the selenium_ package (version > 2.13) into your Python path.
126
 
 
127
 
Then, run the tests normally, for example:
 
123
install the selenium_ package (version > 2.13) into your Python path and run
 
124
the tests with the ``--selenium`` option:
128
125
 
129
126
.. code-block:: bash
130
127
 
131
 
    ./runtests.py --settings=test_sqlite admin_inlines
 
128
    ./runtests.py --settings=test_sqlite --selenium admin_inlines
 
129
 
132
130
 
133
131
.. _running-unit-tests-dependencies:
134
132
 
138
136
If you want to run the full suite of tests, you'll need to install a number of
139
137
dependencies:
140
138
 
141
 
*  PIL_
142
 
*  py-bcrypt_
 
139
*  bcrypt_
 
140
*  docutils_
 
141
*  Pillow_
143
142
*  PyYAML_
144
 
*  Markdown_
145
 
*  Textile_
146
 
*  Docutils_
147
143
*  pytz_
148
144
*  setuptools_
149
145
*  memcached_, plus a :ref:`supported Python binding <memcached>`
168
164
Each of these dependencies is optional. If you're missing any of them, the
169
165
associated tests will be skipped.
170
166
 
171
 
.. _PIL: https://pypi.python.org/pypi/PIL
172
 
.. _py-bcrypt: https://pypi.python.org/pypi/py-bcrypt/
 
167
.. _bcrypt: https://pypi.python.org/pypi/bcrypt
 
168
.. _docutils: https://pypi.python.org/pypi/docutils
 
169
.. _Pillow: https://pypi.python.org/pypi/Pillow/
173
170
.. _PyYAML: http://pyyaml.org/wiki/PyYAML
174
 
.. _Markdown: http://pypi.python.org/pypi/Markdown/1.7
175
 
.. _Textile: http://pypi.python.org/pypi/textile
176
 
.. _docutils: http://pypi.python.org/pypi/docutils/0.4
177
171
.. _pytz: https://pypi.python.org/pypi/pytz/
178
172
.. _setuptools: http://pypi.python.org/pypi/setuptools/
179
173
.. _memcached: http://memcached.org/
213
207
For the tests to be found, a ``models.py`` file must exist, even if it's empty.
214
208
If you have URLs that need to be mapped, put them in ``tests/urls.py``.
215
209
 
216
 
To run tests for just one contrib app (e.g. ``markup``), use the same
 
210
To run tests for just one contrib app (e.g. ``auth``), use the same
217
211
method as above::
218
212
 
219
 
    ./runtests.py --settings=settings markup
 
213
    ./runtests.py --settings=settings django.contrib.auth