From daa467d79ec7b40e376294eabc51222a67690181 Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Thu, 17 Jan 2008 18:12:24 +0000 Subject: newforms-admin: Merged from trunk up to [7021]. git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7022 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/middleware/tests.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'tests/regressiontests/middleware/tests.py') diff --git a/tests/regressiontests/middleware/tests.py b/tests/regressiontests/middleware/tests.py index cb5c29abe1..5e7fd320d6 100644 --- a/tests/regressiontests/middleware/tests.py +++ b/tests/regressiontests/middleware/tests.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- -import unittest - -from django.test import TestCase +from django.test import TestCase from django.http import HttpRequest from django.middleware.common import CommonMiddleware from django.conf import settings @@ -19,7 +17,7 @@ class CommonMiddlewareTest(TestCase): def test_append_slash_have_slash(self): """ - tests that urls with slashes go unmolested + Tests that URLs with slashes go unmolested. """ settings.APPEND_SLASH = True request = self._get_request('slash/') @@ -27,7 +25,7 @@ class CommonMiddlewareTest(TestCase): def test_append_slash_slashless_resource(self): """ - tests that matches to explicit slashless urls go unmolested + Tests that matches to explicit slashless URLs go unmolested. """ settings.APPEND_SLASH = True request = self._get_request('noslash') @@ -35,7 +33,7 @@ class CommonMiddlewareTest(TestCase): def test_append_slash_slashless_unknown(self): """ - tests that APPEND_SLASH doesn't redirect to unknown resources + Tests that APPEND_SLASH doesn't redirect to unknown resources. """ settings.APPEND_SLASH = True request = self._get_request('unknown') @@ -43,7 +41,7 @@ class CommonMiddlewareTest(TestCase): def test_append_slash_redirect(self): """ - tests that APPEND_SLASH redirects slashless urls to a valid pattern + Tests that APPEND_SLASH redirects slashless URLs to a valid pattern. """ settings.APPEND_SLASH = True request = self._get_request('slash') @@ -53,9 +51,9 @@ class CommonMiddlewareTest(TestCase): def test_append_slash_no_redirect_on_POST_in_DEBUG(self): """ - tests that while in debug mode, an exception is raised with a warning - when a failed attempt is made to POST to an url which would normally be - redirected to a slashed version + Tests that while in debug mode, an exception is raised with a warning + when a failed attempt is made to POST to an URL which would normally be + redirected to a slashed version. """ settings.APPEND_SLASH = True settings.DEBUG = True @@ -68,11 +66,12 @@ class CommonMiddlewareTest(TestCase): try: CommonMiddleware().process_request(request) except RuntimeError, e: - self.assertTrue('end in a slash' in str(e)) + self.failUnless('end in a slash' in str(e)) + settings.DEBUG = False def test_append_slash_disabled(self): """ - tests disabling append slash functionality + Tests disabling append slash functionality. """ settings.APPEND_SLASH = False request = self._get_request('slash') @@ -80,8 +79,8 @@ class CommonMiddlewareTest(TestCase): def test_append_slash_quoted(self): """ - tests that urls which require quoting are redirected to their slash - version ok + Tests that URLs which require quoting are redirected to their slash + version ok. """ settings.APPEND_SLASH = True request = self._get_request('needsquoting#') @@ -90,4 +89,3 @@ class CommonMiddlewareTest(TestCase): self.assertEquals( r['Location'], 'http://testserver/middleware/needsquoting%23/') - -- cgit v1.3