Django

Code

Changeset 3737

Show
Ignore:
Timestamp:
09/08/06 08:10:57 (2 years ago)
Author:
russellm
Message:

Clarified some minor issues in test system documentation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/testing.txt

    r3715 r3737  
    9393Like doctests, Django's unit tests use a standard library module: unittest_. 
    9494As 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. 
     95in ``models.py``, or in a ``tests.py`` file stored in the application  
     96directory. 
    9697 
    9798An equivalent unittest test case for the above example would look like:: 
     
    111112 
    112113When 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,  
     116and run that suite. 
    115117 
    116118For more details about ``unittest``, see the `standard library unittest 
     
    198200 
    199201The 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). 
     202that cookie is provided as part of the next request issued to that Client 
     203instance. Expiry policies for these cookies are not followed; if you want  
     204a cookie to expire, either delete it manually from ``client.cookies``, or  
     205create a new Client instance (which will effectively delete all cookies). 
    204206 
    205207Making requests 
     
    211213 
    212214``get(path, data={})`` 
    213  
    214215    Make a GET request on the provided ``path``. The key-value pairs in the 
    215216    data dictionary will be used to create a GET data payload. For example:: 
     
    223224 
    224225``post(path, data={})`` 
    225  
    226226    Make a POST request on the provided ``path``. The key-value pairs in the 
    227227    data dictionary will be used to create the POST data payload. This payload 
     
    244244 
    245245``login(path, username, password)`` 
    246  
    247246    In a production site, it is likely that some views will be protected with 
    248247    the @login_required URL provided by ``django.contrib.auth``. Interacting 
     
    308307            self.client = Client() 
    309308        def test_details(self):         
     309            # Issue a GET request 
    310310            response = self.client.get('/customer/details/') 
    311311     
     312            # Check that the respose is 200 OK 
    312313            self.failUnlessEqual(response.status_code, 200) 
     314            # Check that the rendered context contains 5 customers 
    313315            self.failUnlessEqual(len(response.context['customers']), 5) 
    314316