Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #9607 -- Added documentation for the ``extra`` argument in test…

… client methods. Thanks to jroes for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11173 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 87285078f08f3889cf273c4547022b81cec5733d 1 parent 5cef76f
Russell Keith-Magee authored July 03, 2009

Showing 1 changed file with 23 additions and 6 deletions. Show diff stats Hide diff stats

  1. 29  docs/topics/testing.txt
29  docs/topics/testing.txt
@@ -479,7 +479,7 @@ arguments at time of construction:
479 479
     Once you have a ``Client`` instance, you can call any of the following
480 480
     methods:
481 481
 
482  
-    .. method:: Client.get(path, data={}, follow=False)
  482
+    .. method:: Client.get(path, data={}, follow=False, **extra)
483 483
 
484 484
 
485 485
         Makes a GET request on the provided ``path`` and returns a ``Response``
@@ -495,6 +495,17 @@ arguments at time of construction:
495 495
 
496 496
             /customers/details/?name=fred&age=7
497 497
 
  498
+        The ``extra`` keyword arguments parameter can be used to specify
  499
+        headers to be sent in the request. For example::
  500
+
  501
+            >>> c = Client()
  502
+            >>> c.get('/customers/details/', {'name': 'fred', 'age': 7},
  503
+            ...       HTTP_X_REQUESTED_WITH='XMLHttpRequest')
  504
+
  505
+        ...will send the HTTP header ``HTTP_X_REQUESTED_WITH`` to the
  506
+        details	view, which is a good way to test code paths that use the
  507
+        :meth:`django.http.HttpRequest.is_ajax()` method.
  508
+
498 509
         .. versionadded:: 1.1
499 510
 
500 511
         If you already have the GET arguments in URL-encoded form, you can
@@ -518,7 +529,7 @@ arguments at time of construction:
518 529
             >>> response.redirect_chain
519 530
             [(u'http://testserver/next/', 302), (u'http://testserver/final/', 302)]
520 531
 
521  
-    .. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT, follow=False)
  532
+    .. method:: Client.post(path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)
522 533
 
523 534
         Makes a POST request on the provided ``path`` and returns a
524 535
         ``Response`` object, which is documented below.
@@ -569,6 +580,8 @@ arguments at time of construction:
569 580
         Note that you should manually close the file after it has been provided
570 581
         to ``post()``.
571 582
 
  583
+        The ``extra`` argument acts the same as for :meth:`Client.get`.
  584
+
572 585
         .. versionchanged:: 1.1
573 586
 
574 587
         If the URL you request with a POST contains encoded parameters, these
@@ -585,7 +598,7 @@ arguments at time of construction:
585 598
         and a ``redirect_chain`` attribute will be set in the response object
586 599
         containing tuples of the intermediate urls and status codes.
587 600
 
588  
-    .. method:: Client.head(path, data={}, follow=False)
  601
+    .. method:: Client.head(path, data={}, follow=False, **extra)
589 602
 
590 603
         .. versionadded:: 1.1
591 604
 
@@ -597,7 +610,7 @@ arguments at time of construction:
597 610
         and a ``redirect_chain`` attribute will be set in the response object
598 611
         containing tuples of the intermediate urls and status codes.
599 612
 
600  
-    .. method:: Client.options(path, data={}, follow=False)
  613
+    .. method:: Client.options(path, data={}, follow=False, **extra)
601 614
 
602 615
         .. versionadded:: 1.1
603 616
 
@@ -608,7 +621,9 @@ arguments at time of construction:
608 621
         and a ``redirect_chain`` attribute will be set in the response object
609 622
         containing tuples of the intermediate urls and status codes.
610 623
 
611  
-    .. method:: Client.put(path, data={}, content_type=MULTIPART_CONTENT, follow=False)
  624
+        The ``extra`` argument acts the same as for :meth:`Client.get`.
  625
+
  626
+    .. method:: Client.put(path, data={}, content_type=MULTIPART_CONTENT, follow=False, **extra)
612 627
 
613 628
         .. versionadded:: 1.1
614 629
 
@@ -620,7 +635,7 @@ arguments at time of construction:
620 635
         and a ``redirect_chain`` attribute will be set in the response object
621 636
         containing tuples of the intermediate urls and status codes.
622 637
 
623  
-    .. method:: Client.delete(path, follow=False)
  638
+    .. method:: Client.delete(path, follow=False, **extra)
624 639
 
625 640
         .. versionadded:: 1.1
626 641
 
@@ -631,6 +646,8 @@ arguments at time of construction:
631 646
         and a ``redirect_chain`` attribute will be set in the response object
632 647
         containing tuples of the intermediate urls and status codes.
633 648
 
  649
+        The ``extra`` argument acts the same as for :meth:`Client.get`.
  650
+
634 651
     .. method:: Client.login(**credentials)
635 652
 
636 653
         .. versionadded:: 1.0

0 notes on commit 8728507

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