summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorNatalia <124304+nessita@users.noreply.github.com>2025-07-16 14:08:57 -0300
committernessita <124304+nessita@users.noreply.github.com>2025-07-16 18:11:53 -0300
commita76587531b1f41343ed1f6977a999e4e3a9f6b44 (patch)
treedf8d8233567f1f3348a6341e15028f488bd3a0f4 /django
parentfcc7c12f8013e389276ec33fab7a11935b0af37e (diff)
[5.2.x] Added SimpleTestCase.enterContext() on Python < 3.11.
This reverts commit 47a618d45c6e40dd59f4cdd46fd5fc7d11626f6d and uses a solution similar to ed4f83782d9f3404ad600f6131ef78244ff1e162 instead.
Diffstat (limited to 'django')
-rw-r--r--django/test/testcases.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 36366bd777..98ca963834 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -404,6 +404,10 @@ class SimpleTestCase(unittest.TestCase):
def enterClassContext(cls, cm):
return _enter_context(cm, cls.addClassCleanup)
+ # Backport of unittest.TestCase.enterContext() from Python 3.11.
+ def enterContext(self, cm):
+ return _enter_context(cm, self.addCleanup)
+
def settings(self, **kwargs):
"""
A context manager that temporarily sets a setting and reverts to the