Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extended explanation on how and are handled in

  • Loading branch information...
commit 2df87c45496bf7a9e2da109ffee20d50b40af042 1 parent 0a50311
@karolmajta authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 docs/topics/testing/overview.txt
View
15 docs/topics/testing/overview.txt
@@ -925,9 +925,10 @@ to test the effects of commit and rollback:
* A ``TestCase``, on the other hand, does not truncate tables after a test.
Instead, it encloses the test code in a database transaction that is rolled
- back at the end of the test. It also prevents the code under test from
- issuing any commit or rollback operations on the database, to ensure that the
- rollback at the end of the test restores the database to its initial state.
+ back at the end of the test. Both explicit commits like ``transaction.commit()``
+ and implicit ones that may be caused by ``Model.save()`` are instead replaced
+ with a ``nop`` operation. It guarantees that the rollback at the end of the
+ test restores the database to its initial state.
When running on a database that does not support rollback (e.g. MySQL with the
MyISAM storage engine), ``TestCase`` falls back to initializing the database
@@ -935,6 +936,14 @@ to test the effects of commit and rollback:
.. note::
+ While all ``commit`` and ``rollback`` operations still *appear* to work
+ when used in ``TestCase`` they do not cause any side effect, or more
+ precisely, no actuall commit or rollback will be performed by the database.
+ This can cause your test to pass or fail unexpectedly. Always use
+ ``TransactionalTestCase`` when testing transactional behavior.
+
+.. note::
+
.. versionchanged:: 1.5
Prior to 1.5, ``TransactionTestCase`` flushed the database tables *before*
Please sign in to comment.
Something went wrong with that request. Please try again.