Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move the tests added for #12302 to where some other tests for debug p…

…age responses already existed.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12723 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5a35619b5bf164761c46b796b09335c074fa039d 1 parent bae921d
Karen Tracey kmtracey authored
10 tests/regressiontests/debug/__init__.py
View
@@ -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
-
0  tests/regressiontests/debug/models.py
View
No changes.
21 tests/regressiontests/debug/tests.py
View
@@ -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,)))
-
5 tests/regressiontests/debug/urls.py
View
@@ -1,5 +0,0 @@
-from django.conf.urls.defaults import *
-
-urlpatterns = patterns('regressiontests.debug.views',
- url(r'view_exception/(?P<n>\d+)/$', 'view_exception', name='view_exception'),
-)
5 tests/regressiontests/debug/views.py
View
@@ -1,5 +0,0 @@
-from regressiontests.debug import BrokenException, except_args
-
-def view_exception(request, n):
- raise BrokenException(except_args[int(n)])
-
10 tests/regressiontests/views/__init__.py
View
@@ -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
+
12 tests/regressiontests/views/tests/debug.py
View
@@ -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 @@ def test_files(self):
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,)))
+
3  tests/regressiontests/views/urls.py
View
@@ -107,3 +107,6 @@
{'url': u'/views/中文/target/', 'permanent': True}),
)
+urlpatterns += patterns('regressiontests.views.views',
+ url(r'view_exception/(?P<n>\d+)/$', 'view_exception', name='view_exception'),
+)
7 tests/regressiontests/views/views.py
View
@@ -6,6 +6,8 @@
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)])
+
Please sign in to comment.
Something went wrong with that request. Please try again.