summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-12-05 17:48:58 -0500
committerTim Graham <timograham@gmail.com>2015-12-07 18:33:51 -0500
commit35b5e11a98580e5f5045be36e8901699e39d2867 (patch)
treee87f473eb7129e95ee2adc6719d4da4be73661f4 /docs
parentc0da598077ea475e65741abbba6993e4677fe501 (diff)
[1.9.x] Fixed #25860 -- Documented a transaction leak possiblity in TestCase.
Thanks Jonas Haag for report and review. Backport of a5619f7ed3bc2ca07b428fa0abfaaff088378f48 from master
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/testing/tools.txt13
1 files changed, 11 insertions, 2 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 11e53a409b..b1388cbdcf 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -694,13 +694,22 @@ then you should use :class:`~django.test.TransactionTestCase` or
@classmethod
def setUpClass(cls):
- super(MyTestCase, cls).setUpClass() # Call parent first
+ super(MyTestCase, cls).setUpClass()
...
@classmethod
def tearDownClass(cls):
...
- super(MyTestCase, cls).tearDownClass() # Call parent last
+ super(MyTestCase, cls).tearDownClass()
+
+ Be sure to account for Python's behavior if an exception is raised during
+ ``setUpClass()``. If that happens, neither the tests in the class nor
+ ``tearDownClass()`` are run. In the case of :class:`django.test.TestCase`,
+ this will leak the transaction created in ``super()`` which results in
+ various symptoms including a segmentation fault on some platforms (reported
+ on OS X). If you want to intentionally raise an exception such as
+ :exc:`unittest.SkipTest` in ``setUpClass()``, be sure to do it before
+ calling ``super()`` to avoid this.
TransactionTestCase
~~~~~~~~~~~~~~~~~~~