Explorar o código

Refs #21230 -- removed direct settings manipulation from signed cookies tests

Huu Nguyen %!s(int64=11) %!d(string=hai) anos
pai
achega
b9bfcd82f0
Modificáronse 1 ficheiros con 2 adicións e 9 borrados
  1. 2 9
      tests/signed_cookies_tests/tests.py

+ 2 - 9
tests/signed_cookies_tests/tests.py

@@ -2,10 +2,9 @@ from __future__ import unicode_literals
 
 import time
 
-from django.conf import settings
 from django.core import signing
 from django.http import HttpRequest, HttpResponse
-from django.test import TestCase
+from django.test import TestCase, override_settings
 
 
 class SignedCookieTest(TestCase):
@@ -64,14 +63,8 @@ class SignedCookieTest(TestCase):
         finally:
             time.time = _time
 
+    @override_settings(SECRET_KEY=b'\xe7')
     def test_signed_cookies_with_binary_key(self):
-        def restore_secret_key(prev):
-            settings.SECRET_KEY = prev
-
-        self.addCleanup(restore_secret_key, settings.SECRET_KEY)
-
-        settings.SECRET_KEY = b'\xe7'
-
         response = HttpResponse()
         response.set_signed_cookie('c', 'hello')