1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Used @override_settings in several tests.

This commit is contained in:
Aymeric Augustin
2012-10-20 23:22:46 +02:00
parent 2f722d9728
commit d7c6a57d60
8 changed files with 140 additions and 224 deletions

View File

@@ -1,27 +1,23 @@
from django.conf import settings
from django.core.handlers.wsgi import WSGIHandler
from django.test import RequestFactory
from django.test.utils import override_settings
from django.utils import unittest
class HandlerTests(unittest.TestCase):
# Mangle settings so the handler will fail
@override_settings(MIDDLEWARE_CLASSES=42)
def test_lock_safety(self):
"""
Tests for bug #11193 (errors inside middleware shouldn't leave
the initLock locked).
"""
# Mangle settings so the handler will fail
old_middleware_classes = settings.MIDDLEWARE_CLASSES
settings.MIDDLEWARE_CLASSES = 42
# Try running the handler, it will fail in load_middleware
handler = WSGIHandler()
self.assertEqual(handler.initLock.locked(), False)
with self.assertRaises(Exception):
handler(None, None)
self.assertEqual(handler.initLock.locked(), False)
# Reset settings
settings.MIDDLEWARE_CLASSES = old_middleware_classes
def test_bad_path_info(self):
"""Tests for bug #15672 ('request' referenced before assignment)"""