diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index a82dadceaa..f44a8faac3 100644
a
|
b
|
|
| 1 | import contextlib |
1 | 2 | import os |
2 | 3 | import unittest |
3 | 4 | import warnings |
… |
… |
class TestContextDecoratorTests(SimpleTestCase):
|
1478 | 1479 | with self.assertRaisesMessage(NotImplementedError, 'reraised'): |
1479 | 1480 | decorated_test_class.setUp() |
1480 | 1481 | self.assertTrue(mock_disable.called) |
| 1482 | |
| 1483 | |
| 1484 | class ChangeCSRFCookieName(TestContextDecorator): |
| 1485 | def __init__(self, *args, **kwargs): |
| 1486 | super().__init__(*args, **kwargs) |
| 1487 | self.stack = contextlib.ExitStack() |
| 1488 | |
| 1489 | def enable(self): |
| 1490 | cm = override_settings(CSRF_COOKIE_NAME="cross_site_request_forgery_token") |
| 1491 | self.stack.enter_context(cm) |
| 1492 | |
| 1493 | def disable(self): |
| 1494 | self.stack.close() |
| 1495 | |
| 1496 | |
| 1497 | class ChangeSettingsTestCase(SimpleTestCase): |
| 1498 | def setUp(self): |
| 1499 | super().setUp() |
| 1500 | settings_cm = self.settings(CACHES={}) |
| 1501 | settings_cm.enable() |
| 1502 | self.addCleanup(settings_cm.disable) |
| 1503 | |
| 1504 | |
| 1505 | @ChangeCSRFCookieName() |
| 1506 | class ChangeCSRFCookieNameTest(ChangeSettingsTestCase): |
| 1507 | def test_initial(self): |
| 1508 | pass |
| 1509 | |
| 1510 | |
| 1511 | class LeakTest(SimpleTestCase): |
| 1512 | def test_csrf_cookie_name_has_leaked(self): |
| 1513 | # Should use the default value. |
| 1514 | self.assertEqual("csrftoken", settings.CSRF_COOKIE_NAME) |