Ticket #31944: 31944_repr.patch

File 31944_repr.patch, 1.4 KB (added by François Freitag, 4 years ago)

Patch modifyingt the test suite to reproduce the failure.

  • tests/test_utils/tests.py

    diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
    index a82dadceaa..f44a8faac3 100644
    a b  
     1import contextlib
    12import os
    23import unittest
    34import warnings
    class TestContextDecoratorTests(SimpleTestCase):  
    14781479        with self.assertRaisesMessage(NotImplementedError, 'reraised'):
    14791480            decorated_test_class.setUp()
    14801481        self.assertTrue(mock_disable.called)
     1482
     1483
     1484class 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
     1497class 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()
     1506class ChangeCSRFCookieNameTest(ChangeSettingsTestCase):
     1507    def test_initial(self):
     1508        pass
     1509
     1510
     1511class 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)
Back to Top