Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Middleware regression test fixes:

 * Added a models.py file so the tests run.
 * Reset `settings.DEBUG` to `False` at the end of the `test_append_slash_no_redirect_on_POST_in_DEBUG` test so it doesn't bleed over to other tests.
 * Removed unused import.
 * Minor docstring fixes.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6991 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d6d1188ed0e04009bcd33aa954cf0b2827641433 1 parent 5496c50
Gary Wilson Jr. authored January 03, 2008
1  tests/regressiontests/middleware/models.py
... ...
@@ -0,0 +1 @@
  1
+# models.py file for tests to run.
26  tests/regressiontests/middleware/tests.py
... ...
@@ -1,8 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 
3  
-import unittest
4  
-
5  
-from django.test import TestCase 
  3
+from django.test import TestCase
6 4
 from django.http import HttpRequest
7 5
 from django.middleware.common import CommonMiddleware
8 6
 from django.conf import settings
@@ -19,7 +17,7 @@ def _get_request(self, path):
19 17
 
20 18
     def test_append_slash_have_slash(self):
21 19
         """
22  
-        tests that urls with slashes go unmolested
  20
+        Tests that URLs with slashes go unmolested.
23 21
         """
24 22
         settings.APPEND_SLASH = True
25 23
         request = self._get_request('slash/')
@@ -27,7 +25,7 @@ def test_append_slash_have_slash(self):
27 25
 
28 26
     def test_append_slash_slashless_resource(self):
29 27
         """
30  
-        tests that matches to explicit slashless urls go unmolested
  28
+        Tests that matches to explicit slashless URLs go unmolested.
31 29
         """
32 30
         settings.APPEND_SLASH = True
33 31
         request = self._get_request('noslash')
@@ -35,7 +33,7 @@ def test_append_slash_slashless_resource(self):
35 33
 
36 34
     def test_append_slash_slashless_unknown(self):
37 35
         """
38  
-        tests that APPEND_SLASH doesn't redirect to unknown resources
  36
+        Tests that APPEND_SLASH doesn't redirect to unknown resources.
39 37
         """
40 38
         settings.APPEND_SLASH = True
41 39
         request = self._get_request('unknown')
@@ -43,7 +41,7 @@ def test_append_slash_slashless_unknown(self):
43 41
 
44 42
     def test_append_slash_redirect(self):
45 43
         """
46  
-        tests that APPEND_SLASH redirects slashless urls to a valid pattern
  44
+        Tests that APPEND_SLASH redirects slashless URLs to a valid pattern.
47 45
         """
48 46
         settings.APPEND_SLASH = True
49 47
         request = self._get_request('slash')
@@ -53,9 +51,9 @@ def test_append_slash_redirect(self):
53 51
 
54 52
     def test_append_slash_no_redirect_on_POST_in_DEBUG(self):
55 53
         """
56  
-        tests that while in debug mode, an exception is raised with a warning
57  
-        when a failed attempt is made to POST to an url which would normally be
58  
-        redirected to a slashed version
  54
+        Tests that while in debug mode, an exception is raised with a warning
  55
+        when a failed attempt is made to POST to an URL which would normally be
  56
+        redirected to a slashed version.
59 57
         """
60 58
         settings.APPEND_SLASH = True
61 59
         settings.DEBUG = True
@@ -69,10 +67,11 @@ def test_append_slash_no_redirect_on_POST_in_DEBUG(self):
69 67
             CommonMiddleware().process_request(request)
70 68
         except RuntimeError, e:
71 69
             self.assertTrue('end in a slash' in str(e))
  70
+        settings.DEBUG = False
72 71
 
73 72
     def test_append_slash_disabled(self):
74 73
         """
75  
-        tests disabling append slash functionality
  74
+        Tests disabling append slash functionality.
76 75
         """
77 76
         settings.APPEND_SLASH = False
78 77
         request = self._get_request('slash')
@@ -80,8 +79,8 @@ def test_append_slash_disabled(self):
80 79
 
81 80
     def test_append_slash_quoted(self):
82 81
         """
83  
-        tests that urls which require quoting are redirected to their slash
84  
-        version ok
  82
+        Tests that URLs which require quoting are redirected to their slash
  83
+        version ok.
85 84
         """
86 85
         settings.APPEND_SLASH = True
87 86
         request = self._get_request('needsquoting#')
@@ -90,4 +89,3 @@ def test_append_slash_quoted(self):
90 89
         self.assertEquals(
91 90
             r['Location'],
92 91
             'http://testserver/middleware/needsquoting%23/')
93  
-

0 notes on commit d6d1188

Please sign in to comment.
Something went wrong with that request. Please try again.