Skip to content

Commit

Permalink
Add note on Django TestCase impl to Isolation chapter
Browse files Browse the repository at this point in the history
As suggested by @rodrigondec in #114.
  • Loading branch information
bittner committed Oct 14, 2022
1 parent 3d3e1a3 commit cfaa3d7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions docs/isolation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Test Isolation
Database transactions per scenario
----------------------------------

Each scenario is run inside a database transaction, just like your
regular TestCases. So you can do something like:
Each scenario is run inside a database transaction, just like Django does
it with the related TestCase implementation. So you can do something like:

.. code-block:: python
Expand All @@ -15,3 +15,21 @@ regular TestCases. So you can do something like:
User.objects.create_user(username=username, password='correcthorsebatterystaple')
And you don’t have to clean the database yourself.

Troubleshooting
---------------

.. note::

Users have reported that test isolation and loading fixtures works
differently with different test runners (e.g. when the ``--simple``
option is used). This is likely related to the Django TestCase class
configured for the runner.

Be sure you understand which Django TestCase class is used in your
case, and how it's implemented in Django. See the `runner module`_
and Django's documentation on `Writing and running tests`_ for details.


.. _runner module: https://github.com/behave/behave-django/blob/main/behave_django/runner.py
.. _Writing and running tests: https://docs.djangoproject.com/en/stable/topics/testing/overview/

0 comments on commit cfaa3d7

Please sign in to comment.