From 3565efaa451db6eb735a085ea6aae3fe86e6d283 Mon Sep 17 00:00:00 2001 From: Bouke Haarsma Date: Mon, 14 Oct 2013 15:14:17 +0200 Subject: Removed some direct settings manipulations in tests; refs #21230. --- tests/middleware_exceptions/tests.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'tests/middleware_exceptions') diff --git a/tests/middleware_exceptions/tests.py b/tests/middleware_exceptions/tests.py index fccfdbbd8c..e0f3729e9b 100644 --- a/tests/middleware_exceptions/tests.py +++ b/tests/middleware_exceptions/tests.py @@ -6,6 +6,7 @@ from django.http import HttpResponse from django.template.response import TemplateResponse from django.template import Template from django.test import TestCase +from django.test.utils import override_settings class TestException(Exception): pass @@ -772,15 +773,11 @@ _missing = object() class RootUrlconfTests(TestCase): urls = 'middleware_exceptions.urls' + @override_settings(ROOT_URLCONF=None) def test_missing_root_urlconf(self): - try: - original_ROOT_URLCONF = settings.ROOT_URLCONF - del settings.ROOT_URLCONF - except AttributeError: - original_ROOT_URLCONF = _missing + # Removing ROOT_URLCONF is safe, as override_settings will restore + # the previously defined settings. + del settings.ROOT_URLCONF self.assertRaises(AttributeError, self.client.get, "/middleware_exceptions/view/" ) - - if original_ROOT_URLCONF is not _missing: - settings.ROOT_URLCONF = original_ROOT_URLCONF -- cgit v1.2.1