summaryrefslogtreecommitdiff
path: root/docs/internals/contributing/writing-code/unit-tests.txt
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/internals/contributing/writing-code/unit-tests.txt
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/internals/contributing/writing-code/unit-tests.txt')
-rw-r--r--docs/internals/contributing/writing-code/unit-tests.txt18
1 files changed, 13 insertions, 5 deletions
diff --git a/docs/internals/contributing/writing-code/unit-tests.txt b/docs/internals/contributing/writing-code/unit-tests.txt
index 6067e9635d..df50a636b8 100644
--- a/docs/internals/contributing/writing-code/unit-tests.txt
+++ b/docs/internals/contributing/writing-code/unit-tests.txt
@@ -286,7 +286,7 @@ For example, suppose that the failing test that works on its own is
.. code-block:: bash
- $ ./runtests.py --bisect basic.tests.ModelTest.test_eq
+ $ ./runtests.py --bisect basic.tests.ModelTest.test_eq
will try to determine a test that interferes with the given one. First, the
test is run with the first half of the test suite. If a failure occurs, the
@@ -302,7 +302,7 @@ failure. So:
.. code-block:: bash
- $ ./runtests.py --pair basic.tests.ModelTest.test_eq
+ $ ./runtests.py --pair basic.tests.ModelTest.test_eq
will pair ``test_eq`` with every test label.
@@ -313,7 +313,7 @@ the first one:
.. code-block:: bash
- $ ./runtests.py --pair basic.tests.ModelTest.test_eq queries transactions
+ $ ./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
@@ -321,8 +321,16 @@ cause any trouble:
.. code-block:: bash
- $ ./runtests.py basic --reverse
+ $ ./runtests.py basic --reverse
+
+If you wish to examine the SQL being run in failing tests, you can turn on
+:ref:`SQL logging <django-db-logger>` using the ``--debug-sql`` option. If you
+combine this with ``--verbosity=2``, all SQL queries will be output.
+
+.. code-block:: bash
+
+ $ ./runtests.py basic --debug-sql
.. versionadded:: 1.8
- The ``--reverse`` option was added.
+ The ``--reverse`` and ``--debug-sql`` options were added.