diff options
| author | Chris Wilson <chris+github@qwirx.com> | 2013-11-27 19:45:20 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-02-07 15:29:25 -0500 |
| commit | 65131911dba08dcc1451d71ae4d5101724d722f6 (patch) | |
| tree | 6086c55b6df3dba9dd9c8405a66748a4cbe8d810 /tests/test_utils | |
| parent | 43510cffcbf64e73232da1d6209151c7232fd2b6 (diff) | |
Fixed #21518 -- Made override_settings(ROOT_URLCONF) clear the resolver cache.
Thanks Aymeric Augustin and Simon Charette for reviews.
Diffstat (limited to 'tests/test_utils')
| -rw-r--r-- | tests/test_utils/tests.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index 999b59faea..365341d50f 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -3,13 +3,16 @@ from __future__ import unicode_literals import unittest +from django.conf.urls import patterns, url +from django.core.urlresolvers import reverse from django.db import connection from django.forms import EmailField, IntegerField from django.http import HttpResponse from django.template.loader import render_to_string from django.test import SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature from django.test.html import HTMLParseError, parse_html -from django.test.utils import CaptureQueriesContext, IgnoreAllDeprecationWarningsMixin +from django.test.utils import (CaptureQueriesContext, + IgnoreAllDeprecationWarningsMixin, override_settings) from django.utils import six from .models import Person @@ -627,3 +630,32 @@ class DoctestNormalizerTest(IgnoreAllDeprecationWarningsMixin, SimpleTestCase): suite = make_doctest("test_utils.doctest_output") failures = unittest.TextTestRunner(stream=six.StringIO()).run(suite) self.assertEqual(failures.failures, []) + + +# for OverrideSettingsTests +def fake_view(request): + pass + + +class FirstUrls: + urlpatterns = patterns('', url(r'first/$', fake_view, name='first')) + + +class SecondUrls: + urlpatterns = patterns('', url(r'second/$', fake_view, name='second')) + + +class OverrideSettingsTests(TestCase): + """ + #21518 -- If neither override_settings nor a settings_changed receiver + clears the URL cache between tests, then one of these two test methods will + fail. + """ + + @override_settings(ROOT_URLCONF=FirstUrls) + def test_first(self): + reverse('first') + + @override_settings(ROOT_URLCONF=SecondUrls) + def test_second(self): + reverse('second') |
