mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
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.
This commit is contained in:
parent
ca801b8c8f
commit
e22c64dfc0
9 changed files with 142 additions and 16 deletions
|
@ -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
|
||||
~~~~~~~~~~
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue