Updated docs and runtests.py for removal of tests from contrib.
This commit is contained in:
parent
ad0be620ae
commit
7cf3a5786b
|
@ -5,11 +5,6 @@ Unit tests
|
||||||
Django comes with a test suite of its own, in the ``tests`` directory of the
|
Django comes with a test suite of its own, in the ``tests`` directory of the
|
||||||
code base. It's our policy to make sure all tests pass at all times.
|
code base. It's our policy to make sure all tests pass at all times.
|
||||||
|
|
||||||
The tests cover:
|
|
||||||
|
|
||||||
* Models, the database API and everything else in core Django core (``tests/``),
|
|
||||||
* :ref:`contrib-apps` (``django/contrib/<app>/tests`` or ``tests/<app>_...``).
|
|
||||||
|
|
||||||
We appreciate any and all contributions to the test suite!
|
We appreciate any and all contributions to the test suite!
|
||||||
|
|
||||||
The Django tests all use the testing infrastructure that ships with Django for
|
The Django tests all use the testing infrastructure that ships with Django for
|
||||||
|
@ -108,8 +103,7 @@ internationalization, type:
|
||||||
$ ./runtests.py --settings=path.to.settings generic_relations i18n
|
$ ./runtests.py --settings=path.to.settings generic_relations i18n
|
||||||
|
|
||||||
How do you find out the names of individual tests? Look in ``tests/`` — each
|
How do you find out the names of individual tests? Look in ``tests/`` — each
|
||||||
directory name there is the name of a test. Contrib app names are also valid
|
directory name there is the name of a test.
|
||||||
test names.
|
|
||||||
|
|
||||||
If you just want to run a particular class of tests, you can specify a list of
|
If you just want to run a particular class of tests, you can specify a list of
|
||||||
paths to individual test classes. For example, to run the ``TranslationTests``
|
paths to individual test classes. For example, to run the ``TranslationTests``
|
||||||
|
@ -221,18 +215,9 @@ and also excludes several directories not relevant to the results
|
||||||
Contrib apps
|
Contrib apps
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Tests for contrib apps go in their respective directories under
|
Tests for contrib apps can be found in the ``tests/`` directory, typically
|
||||||
``django/contrib``, in a ``tests.py`` file. You can split the tests over
|
under ``<app_name>_tests``. For example, tests for ``contrib.auth`` are located
|
||||||
multiple modules by using a ``tests`` directory in the normal Python way.
|
in ``tests/auth_tests``.
|
||||||
|
|
||||||
If you have URLs that need to be mapped, put them in ``tests/urls.py``.
|
|
||||||
|
|
||||||
To run tests for just one contrib app (e.g. ``auth``), use the same
|
|
||||||
method as above:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ ./runtests.py --settings=settings django.contrib.auth
|
|
||||||
|
|
||||||
.. _troubleshooting-unit-tests:
|
.. _troubleshooting-unit-tests:
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import warnings
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from django import contrib
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
@ -24,9 +23,6 @@ from django.utils.deprecation import (
|
||||||
warnings.simplefilter("error", RemovedInDjango20Warning)
|
warnings.simplefilter("error", RemovedInDjango20Warning)
|
||||||
warnings.simplefilter("error", RemovedInDjango21Warning)
|
warnings.simplefilter("error", RemovedInDjango21Warning)
|
||||||
|
|
||||||
CONTRIB_MODULE_PATH = 'django.contrib'
|
|
||||||
|
|
||||||
CONTRIB_DIR = os.path.dirname(upath(contrib.__file__))
|
|
||||||
RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
|
RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
|
||||||
|
|
||||||
TEMPLATE_DIR = os.path.join(RUNTESTS_DIR, 'templates')
|
TEMPLATE_DIR = os.path.join(RUNTESTS_DIR, 'templates')
|
||||||
|
@ -74,7 +70,6 @@ def get_test_modules():
|
||||||
modules = []
|
modules = []
|
||||||
discovery_paths = [
|
discovery_paths = [
|
||||||
(None, RUNTESTS_DIR),
|
(None, RUNTESTS_DIR),
|
||||||
(CONTRIB_MODULE_PATH, CONTRIB_DIR)
|
|
||||||
]
|
]
|
||||||
# GIS tests are in nested apps
|
# GIS tests are in nested apps
|
||||||
if connection.features.gis_enabled:
|
if connection.features.gis_enabled:
|
||||||
|
@ -177,11 +172,7 @@ def setup(verbosity, test_labels):
|
||||||
# Reduce given test labels to just the app module path
|
# Reduce given test labels to just the app module path
|
||||||
test_labels_set = set()
|
test_labels_set = set()
|
||||||
for label in test_labels:
|
for label in test_labels:
|
||||||
bits = label.split('.')
|
bits = label.split('.')[:1]
|
||||||
if bits[:2] == ['django', 'contrib']:
|
|
||||||
bits = bits[:3]
|
|
||||||
else:
|
|
||||||
bits = bits[:1]
|
|
||||||
test_labels_set.add('.'.join(bits))
|
test_labels_set.add('.'.join(bits))
|
||||||
|
|
||||||
installed_app_names = set(get_installed())
|
installed_app_names = set(get_installed())
|
||||||
|
|
Loading…
Reference in New Issue