diff options
| author | Arthur Vuillard <arthur.vuillard@gmail.com> | 2013-02-21 16:34:16 +0100 |
|---|---|---|
| committer | Arthur Vuillard <arthur.vuillard@gmail.com> | 2013-02-21 16:34:16 +0100 |
| commit | 7a3fcf2beb079f561436101365dc140a7a982bb3 (patch) | |
| tree | 0cd2c02a77c940f669e3c48aa7dba46603c0434d /docs | |
| parent | d11bd587f59de7b0a2998c0349311946b639d0cf (diff) | |
| parent | 55e4b346e6a0cfe071951be4c1b0e06835a42a25 (diff) | |
| download | webtest-7a3fcf2beb079f561436101365dc140a7a982bb3.tar.gz | |
Merge https://github.com/harobed/webtest
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/contributing.txt | 6 | ||||
| -rw-r--r-- | docs/debugapp.txt | 32 | ||||
| -rw-r--r-- | docs/webtest.txt | 7 |
3 files changed, 44 insertions, 1 deletions
diff --git a/docs/contributing.txt b/docs/contributing.txt index bb05939..1ca581b 100644 --- a/docs/contributing.txt +++ b/docs/contributing.txt @@ -71,3 +71,9 @@ Generate documentation build succeeded, 3 warnings. Build finished. The HTML pages are in _build/html. + + +Tips +==== + +You can use :doc:`debugapp` object to test *webtest*. diff --git a/docs/debugapp.txt b/docs/debugapp.txt index 404ff2c..c33ab10 100644 --- a/docs/debugapp.txt +++ b/docs/debugapp.txt @@ -2,7 +2,37 @@ Debug application ================= -.. automodule:: webtest.debugapp +``webtest.debugapp.debug_app`` is a faker WSGI app to help to test *webtest*. + +Examples of use : + +.. code-block:: python + + >>> import webtest + >>> from webtest.debugapp import debug_app + >>> app = webtest.TestApp(debug_app) + >>> res = app.post('/', params='foobar') + >>> print(res.body) + CONTENT_LENGTH: 6 + CONTENT_TYPE: application/x-www-form-urlencoded + HTTP_HOST: localhost:80 + ... + wsgi.url_scheme: 'http' + wsgi.version: (1, 0) + -- Body ---------- + foobar + +Here, you can see, ``foobar`` in *body* when you pass ``foobar`` in ``app.post`` ``params`` argument. + +You can also define the status of response : + + >>> res = app.post('/?status=302', params='foobar') + >>> print(res.status) + 302 Found + + +Complete ``debugapp.py`` source code +==================================== .. literalinclude:: ../webtest/debugapp.py :pyobject: DebugApp diff --git a/docs/webtest.txt b/docs/webtest.txt index 5a2b86f..b40c0de 100644 --- a/docs/webtest.txt +++ b/docs/webtest.txt @@ -118,6 +118,9 @@ The inherited attributes that are most interesting: ``response.text``: The unicode text body of the response. +``response.normal_body``: + The whitespace-normalized [#whitespace-normalized]_ body of the response. + ``response.request``: The `webob.Request object <http://docs.webob.org/en/latest/reference.html#request>`_ used to generate @@ -160,6 +163,10 @@ The added methods: If there is just a single form, this returns that. It is an error if you use this and there are multiple forms. +.. rubric:: Footnotes + +.. [#whitespace-normalized] The whitespace normalization replace sequences of whitespace characters and ``\n`` ``\r`` ``\t`` by a single space. + Parsing the Body ---------------- |
