Fixed #31944 -- Used addCleanup() to register TestContextDecorator cleanups.

Cleanups from addCleanup() are scheduled to happen in reverse order to
the order they are added (LIFO). Ensures each cleanup is executed from
the innermost to the outermost.
This commit is contained in:
François Freitag 2020-09-06 14:36:20 +02:00 committed by Mariusz Felisiak
parent 11ebc6479f
commit 57dadfac3c
3 changed files with 30 additions and 11 deletions

View file

@ -484,6 +484,11 @@ Miscellaneous
* The undocumented ``django.utils.http.limited_parse_qsl()`` function is
removed. Please use :func:`urllib.parse.parse_qsl` instead.
* ``django.test.utils.TestContextDecorator`` now uses
:py:meth:`~unittest.TestCase.addCleanup` so that cleanups registered in the
:py:meth:`~unittest.TestCase.setUp` method are called before
``TestContextDecorator.disable()``.
.. _deprecated-features-3.2:
Features deprecated in 3.2