Fixed #24652 -- Disallowed query execution in SimpleTestCase subclasses.

Thanks to Tim and Anssi for the review.
This commit is contained in:
Simon Charette 2015-04-16 16:19:30 -04:00
parent ead36e8a47
commit c15b0c2792
4 changed files with 64 additions and 0 deletions

View file

@ -505,6 +505,12 @@ Miscellaneous
* The ``django.contrib.sites.models.Site.domain`` field was changed to be
:attr:`~django.db.models.Field.unique`.
* In order to enforce test isolation, database queries are not allowed
by default in :class:`~django.test.SimpleTestCase` tests anymore. You
can disable this behavior by setting the
:attr:`~django.test.SimpleTestCase.allow_database_queries` class attribute
to ``True`` on your test class.
.. _deprecated-features-1.9:
Features deprecated in 1.9

View file

@ -606,6 +606,17 @@ features like:
then you should use :class:`~django.test.TransactionTestCase` or
:class:`~django.test.TestCase` instead.
.. attribute:: SimpleTestCase.allow_database_queries
.. versionadded:: 1.9
:class:`~SimpleTestCase` disallows database queries by default. This
helps to avoid executing write queries which will affect other tests
since each ``SimpleTestCase`` test isn't run in a transaction. If you
aren't concerned about this problem, you can disable this behavior by
setting the ``allow_database_queries`` class attribute to ``True`` on
your test class.
``SimpleTestCase`` inherits from ``unittest.TestCase``.
.. warning::