summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorwrwrwr <git@wr.waw.pl>2014-11-22 17:59:05 +0100
committerTim Graham <timograham@gmail.com>2014-11-24 19:24:11 -0500
commite22c64dfc0230134c0e9d9ae1d9a5c1589fc8b6e (patch)
tree392a0fda9c438eeb3d2c48c3130c149d3db63d3f /docs
parentca801b8c8f7022cd9334a89ac9ae03f586650234 (diff)
Fixed #23742 -- Added an option to reverse tests order.
This is useful for debugging side effects affecting tests that are usually executed before a given test. Full suite and pair tests sort cases more or less deterministically, thus some test cross-dependencies are easier to reveal by reversing the order. Thanks Preston Timmons for the review.
Diffstat (limited to 'docs')
-rw-r--r--docs/internals/contributing/writing-code/unit-tests.txt12
-rw-r--r--docs/ref/django-admin.txt9
-rw-r--r--docs/releases/1.8.txt5
-rw-r--r--docs/topics/testing/advanced.txt9
-rw-r--r--docs/topics/testing/overview.txt6
5 files changed, 37 insertions, 4 deletions
diff --git a/docs/internals/contributing/writing-code/unit-tests.txt b/docs/internals/contributing/writing-code/unit-tests.txt
index 286fd36f9c..2497c5e65a 100644
--- a/docs/internals/contributing/writing-code/unit-tests.txt
+++ b/docs/internals/contributing/writing-code/unit-tests.txt
@@ -307,3 +307,15 @@ the first one:
.. code-block:: bash
$ ./runtests.py --pair basic.tests.ModelTest.test_eq queries transactions
+
+You can also try running any set of tests in reverse using the ``--reverse``
+option in order to verify that executing tests in a different order does not
+cause any trouble:
+
+.. code-block:: bash
+
+ $ ./runtests.py basic --reverse
+
+.. versionadded:: 1.8
+
+ The ``--reverse`` option was added.
diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
index 2c42c01096..ca0d7101ef 100644
--- a/docs/ref/django-admin.txt
+++ b/docs/ref/django-admin.txt
@@ -1411,6 +1411,15 @@ test suite. If the test database does not exist, it will be created on the first
run and then preserved for each subsequent run. Any unapplied migrations will also
be applied to the test database before running the test suite.
+.. django-admin-option:: --reverse
+
+.. versionadded:: 1.8
+
+The ``--reverse`` option can be used to sort test cases in the opposite order.
+This may help in debugging tests that aren't properly isolated and have side
+effects. :ref:`Grouping by test class <order-of-tests>` is preserved when using
+this option.
+
testserver <fixture fixture ...>
--------------------------------
diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
index 867f021b6a..7064891312 100644
--- a/docs/releases/1.8.txt
+++ b/docs/releases/1.8.txt
@@ -471,8 +471,9 @@ Tests
* The new :meth:`~django.test.SimpleTestCase.assertJSONNotEqual` assertion
allows you to test that two JSON fragments are not equal.
-* Added the ability to preserve the test database by adding the
- :djadminopt:`--keepdb` flag.
+* Added options to the :djadmin:`test` command to preserve the test database
+ (:djadminopt:`--keepdb`) and to run the test cases in reverse order
+ (:djadminopt:`--reverse`).
* Added the :attr:`~django.test.Response.resolver_match` attribute to test
client responses.
diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt
index 414f1f515a..7865056e31 100644
--- a/docs/topics/testing/advanced.txt
+++ b/docs/topics/testing/advanced.txt
@@ -355,7 +355,7 @@ behavior. This class defines the ``run_tests()`` entry point, plus a
selection of other methods that are used to by ``run_tests()`` to set up,
execute and tear down the test suite.
-.. class:: DiscoverRunner(pattern='test*.py', top_level=None, verbosity=1, interactive=True, failfast=True, keepdb=False **kwargs)
+.. class:: DiscoverRunner(pattern='test*.py', top_level=None, verbosity=1, interactive=True, failfast=True, keepdb=False, reverse=False, **kwargs)
``DiscoverRunner`` will search for tests in any file matching ``pattern``.
@@ -381,6 +381,11 @@ execute and tear down the test suite.
or create one if necessary. If ``False``, a new database will be created,
prompting the user to remove the existing one, if present.
+ If ``reverse`` is ``True``, test cases will be executed in the opposite
+ order. This could be useful to debug tests that aren't properly isolated
+ and have side effects. :ref:`Grouping by test class <order-of-tests>` is
+ preserved when using this option.
+
Django may, from time to time, extend the capabilities of the test runner
by adding new arguments. The ``**kwargs`` declaration allows for this
expansion. If you subclass ``DiscoverRunner`` or write your own test
@@ -397,7 +402,7 @@ execute and tear down the test suite.
subclassed test runner to add options to the list of command-line
options that the :djadmin:`test` command could use.
- The ``keepdb`` argument was added.
+ The ``keepdb`` and the ``reverse`` arguments were added.
Attributes
~~~~~~~~~~
diff --git a/docs/topics/testing/overview.txt b/docs/topics/testing/overview.txt
index 5104521f3b..913820adf5 100644
--- a/docs/topics/testing/overview.txt
+++ b/docs/topics/testing/overview.txt
@@ -234,6 +234,12 @@ the Django test runner reorders tests in the following way:
database by a given :class:`~django.test.TransactionTestCase` test, they
must be updated to be able to run independently.
+.. versionadded:: 1.8
+
+ You may reverse the execution order inside groups by passing
+ :djadminopt:`--reverse` to the test command. This can help with ensuring
+ your tests are independent from each other.
+
.. _test-case-serialized-rollback:
Rollback emulation