From 5a35619b5bf164761c46b796b09335c074fa039d Mon Sep 17 00:00:00 2001 From: Karen Tracey Date: Mon, 8 Mar 2010 15:20:29 +0000 Subject: [PATCH] Move the tests added for #12302 to where some other tests for debug page responses already existed. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12723 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/debug/__init__.py | 10 ---------- tests/regressiontests/debug/models.py | 0 tests/regressiontests/debug/tests.py | 21 --------------------- tests/regressiontests/debug/urls.py | 5 ----- tests/regressiontests/debug/views.py | 5 ----- tests/regressiontests/views/__init__.py | 10 ++++++++++ tests/regressiontests/views/tests/debug.py | 12 +++++++++++- tests/regressiontests/views/urls.py | 3 +++ tests/regressiontests/views/views.py | 7 ++++++- 9 files changed, 30 insertions(+), 43 deletions(-) delete mode 100644 tests/regressiontests/debug/__init__.py delete mode 100644 tests/regressiontests/debug/models.py delete mode 100644 tests/regressiontests/debug/tests.py delete mode 100644 tests/regressiontests/debug/urls.py delete mode 100644 tests/regressiontests/debug/views.py diff --git a/tests/regressiontests/debug/__init__.py b/tests/regressiontests/debug/__init__.py deleted file mode 100644 index d1c6e08f35..0000000000 --- a/tests/regressiontests/debug/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf8 -*- - -class BrokenException(Exception): - pass - -except_args = ('Broken!', # plain exception with ASCII text - u'¡Broken!', # non-ASCII unicode data - '¡Broken!', # non-ASCII, utf-8 encoded bytestring - '\xa1Broken!', ) # non-ASCII, latin1 bytestring - diff --git a/tests/regressiontests/debug/models.py b/tests/regressiontests/debug/models.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/regressiontests/debug/tests.py b/tests/regressiontests/debug/tests.py deleted file mode 100644 index b99445d432..0000000000 --- a/tests/regressiontests/debug/tests.py +++ /dev/null @@ -1,21 +0,0 @@ -from django.test import TestCase -from django.conf import settings -from django.core.urlresolvers import reverse - -from regressiontests.debug import BrokenException, except_args - -class ExceptionTest(TestCase): - urls = 'regressiontests.debug.urls' - - def setUp(self): - self.old_debug = settings.DEBUG - settings.DEBUG = True - - def tearDown(self): - settings.DEBUG = self.old_debug - - def test_view_exceptions(self): - for n in range(len(except_args)): - self.assertRaises(BrokenException, self.client.get, - reverse('view_exception', args=(n,))) - diff --git a/tests/regressiontests/debug/urls.py b/tests/regressiontests/debug/urls.py deleted file mode 100644 index 762ab2d632..0000000000 --- a/tests/regressiontests/debug/urls.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.conf.urls.defaults import * - -urlpatterns = patterns('regressiontests.debug.views', - url(r'view_exception/(?P\d+)/$', 'view_exception', name='view_exception'), -) diff --git a/tests/regressiontests/debug/views.py b/tests/regressiontests/debug/views.py deleted file mode 100644 index e58e1ca637..0000000000 --- a/tests/regressiontests/debug/views.py +++ /dev/null @@ -1,5 +0,0 @@ -from regressiontests.debug import BrokenException, except_args - -def view_exception(request, n): - raise BrokenException(except_args[int(n)]) - diff --git a/tests/regressiontests/views/__init__.py b/tests/regressiontests/views/__init__.py index e69de29bb2..d1c6e08f35 100644 --- a/tests/regressiontests/views/__init__.py +++ b/tests/regressiontests/views/__init__.py @@ -0,0 +1,10 @@ +# -*- coding: utf8 -*- + +class BrokenException(Exception): + pass + +except_args = ('Broken!', # plain exception with ASCII text + u'¡Broken!', # non-ASCII unicode data + '¡Broken!', # non-ASCII, utf-8 encoded bytestring + '\xa1Broken!', ) # non-ASCII, latin1 bytestring + diff --git a/tests/regressiontests/views/tests/debug.py b/tests/regressiontests/views/tests/debug.py index 5431c19932..0ff4ec3d6b 100644 --- a/tests/regressiontests/views/tests/debug.py +++ b/tests/regressiontests/views/tests/debug.py @@ -1,13 +1,17 @@ from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.test import TestCase +from django.core.urlresolvers import reverse + +from regressiontests.views import BrokenException, except_args class DebugViewTests(TestCase): def setUp(self): + self.old_debug = settings.DEBUG settings.DEBUG = True def tearDown(self): - settings.DEBUG = False + settings.DEBUG = self.old_debug def test_files(self): response = self.client.get('/views/raises/') @@ -23,3 +27,9 @@ class DebugViewTests(TestCase): def test_404(self): response = self.client.get('/views/raises404/') self.assertEquals(response.status_code, 404) + + def test_view_exceptions(self): + for n in range(len(except_args)): + self.assertRaises(BrokenException, self.client.get, + reverse('view_exception', args=(n,))) + diff --git a/tests/regressiontests/views/urls.py b/tests/regressiontests/views/urls.py index bd95dacd06..6d36bb9f62 100644 --- a/tests/regressiontests/views/urls.py +++ b/tests/regressiontests/views/urls.py @@ -107,3 +107,6 @@ urlpatterns += patterns('django.views.generic.simple', {'url': u'/views/中文/target/', 'permanent': True}), ) +urlpatterns += patterns('regressiontests.views.views', + url(r'view_exception/(?P\d+)/$', 'view_exception', name='view_exception'), +) diff --git a/tests/regressiontests/views/views.py b/tests/regressiontests/views/views.py index f54de91c80..e1167f1b63 100644 --- a/tests/regressiontests/views/views.py +++ b/tests/regressiontests/views/views.py @@ -6,6 +6,8 @@ from django.views.debug import technical_500_response from django.views.generic.create_update import create_object from django.core.urlresolvers import get_resolver +from regressiontests.views import BrokenException, except_args + from models import Article @@ -40,10 +42,13 @@ def raises(request): def raises404(request): resolver = get_resolver(None) resolver.resolve('') - + def redirect(request): """ Forces an HTTP redirect. """ return HttpResponseRedirect("target/") +def view_exception(request, n): + raise BrokenException(except_args[int(n)]) +