Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Clarified some minor issues in test system documentation.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3737 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5b34781f2808963c003642aa05c3ea25fe1c9fe3 1 parent e9b19df
Russell Keith-Magee authored September 08, 2006

Showing 1 changed file with 12 additions and 10 deletions. Show diff stats Hide diff stats

  1. 22  docs/testing.txt
22  docs/testing.txt
@@ -92,7 +92,8 @@ Writing unittests
92 92
 
93 93
 Like doctests, Django's unit tests use a standard library module: unittest_.
94 94
 As with doctests, Django's test runner looks for any unit test cases defined
95  
-in ``models.py``, or in a ``tests.py`` file in your application directory.
  95
+in ``models.py``, or in a ``tests.py`` file stored in the application 
  96
+directory.
96 97
 
97 98
 An equivalent unittest test case for the above example would look like::
98 99
 
@@ -110,8 +111,9 @@ An equivalent unittest test case for the above example would look like::
110 111
             self.assertEquals(self.cat.speak(), 'The cat says "meow"')
111 112
 
112 113
 When you `run your tests`_, the test utility will find all the test cases
113  
-(that is, subclasses of ``unittest.TestCase``) in ``tests.py``, automatically
114  
-build a test suite out of those test cases, and run that suite.
  114
+(that is, subclasses of ``unittest.TestCase``) in ``models.py`` and 
  115
+``tests.py``, automatically build a test suite out of those test cases, 
  116
+and run that suite.
115 117
 
116 118
 For more details about ``unittest``, see the `standard library unittest
117 119
 documentation`_.
@@ -197,10 +199,10 @@ used as test conditions.
197 199
 .. _Selenium: http://www.openqa.org/selenium/
198 200
 
199 201
 The Test Client is stateful; if a cookie is returned as part of a response,
200  
-that cookie is provided as part of the next request. Expiry policies for these
201  
-cookies are not followed; if you want a cookie to expire, either delete it 
202  
-manually from ``client.cookies``, or create a new Client instance (which will
203  
-effectively delete all cookies).
  202
+that cookie is provided as part of the next request issued to that Client
  203
+instance. Expiry policies for these cookies are not followed; if you want 
  204
+a cookie to expire, either delete it manually from ``client.cookies``, or 
  205
+create a new Client instance (which will effectively delete all cookies).
204 206
 
205 207
 Making requests
206 208
 ~~~~~~~~~~~~~~~
@@ -210,7 +212,6 @@ no arguments at time of construction. Once constructed, the following methods
210 212
 can be invoked on the ``Client`` instance.
211 213
 
212 214
 ``get(path, data={})``
213  
-
214 215
     Make a GET request on the provided ``path``. The key-value pairs in the
215 216
     data dictionary will be used to create a GET data payload. For example::
216 217
 
@@ -222,7 +223,6 @@ can be invoked on the ``Client`` instance.
222 223
         http://yoursite.com/customers/details/?name='fred'&age=7
223 224
 
224 225
 ``post(path, data={})``
225  
-
226 226
     Make a POST request on the provided ``path``. The key-value pairs in the
227 227
     data dictionary will be used to create the POST data payload. This payload
228 228
     will be transmitted with the mimetype ``multipart/form-data``. 
@@ -243,7 +243,6 @@ can be invoked on the ``Client`` instance.
243 243
     need to manually close the file after it has been provided to the POST.
244 244
 
245 245
 ``login(path, username, password)``
246  
-
247 246
     In a production site, it is likely that some views will be protected with
248 247
     the @login_required URL provided by ``django.contrib.auth``. Interacting
249 248
     with a URL that has been login protected is a slightly complex operation,
@@ -307,9 +306,12 @@ The following is a simple unit test using the Test Client::
307 306
             # Every test needs a client
308 307
             self.client = Client()
309 308
         def test_details(self):        
  309
+            # Issue a GET request
310 310
             response = self.client.get('/customer/details/')
311 311
     
  312
+            # Check that the respose is 200 OK
312 313
             self.failUnlessEqual(response.status_code, 200)
  314
+            # Check that the rendered context contains 5 customers
313 315
             self.failUnlessEqual(len(response.context['customers']), 5)
314 316
 
315 317
 Fixtures

0 notes on commit 5b34781

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