summaryrefslogtreecommitdiff
path: root/docs/topics/testing
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2015-01-10 22:52:59 +0000
committerMarc Tamlyn <marc.tamlyn@gmail.com>2015-01-12 08:16:08 +0000
commitb5c1a85b50c709770b8e98aeecfeb8e81ca29dcf (patch)
tree6291a3d178695605e808f4fa75b56e2553681f48 /docs/topics/testing
parent68a439a18da17a65555832eff0a7c2090655b583 (diff)
Fixed #24118 -- Added --debug-sql option for tests.
Added a --debug-sql option for tests and runtests.py which outputs the SQL logger for failing tests. When combined with --verbosity=2, it also outputs the SQL for passing tests. Thanks to Berker, Tim, Markus, Shai, Josh and Anssi for review and discussion.
Diffstat (limited to 'docs/topics/testing')
-rw-r--r--docs/topics/testing/advanced.txt9
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt
index 7865056e31..c995d5ec5c 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, reverse=False, **kwargs)
+.. class:: DiscoverRunner(pattern='test*.py', top_level=None, verbosity=1, interactive=True, failfast=True, keepdb=False, reverse=False, debug_sql=False, **kwargs)
``DiscoverRunner`` will search for tests in any file matching ``pattern``.
@@ -386,6 +386,11 @@ execute and tear down the test suite.
and have side effects. :ref:`Grouping by test class <order-of-tests>` is
preserved when using this option.
+ If ``debug_sql`` is ``True``, failing test cases will output SQL queries
+ logged to the :ref:`django.db.backends logger <django-db-logger>` as well
+ as the traceback. If ``verbosity`` is ``2``, then queries in all tests are
+ output.
+
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
@@ -402,7 +407,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`` and the ``reverse`` arguments were added.
+ The ``keepdb``, ``reverse``, and ``debug_sql`` arguments were added.
Attributes
~~~~~~~~~~