diff options
| author | Natalia <124304+nessita@users.noreply.github.com> | 2025-07-16 14:08:57 -0300 |
|---|---|---|
| committer | nessita <124304+nessita@users.noreply.github.com> | 2025-07-16 18:11:53 -0300 |
| commit | a76587531b1f41343ed1f6977a999e4e3a9f6b44 (patch) | |
| tree | df8d8233567f1f3348a6341e15028f488bd3a0f4 /django | |
| parent | fcc7c12f8013e389276ec33fab7a11935b0af37e (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.py | 4 |
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 |
