diff options
| author | Gael Pasgrimaud <gael@gawel.org> | 2013-01-29 13:42:21 +0100 |
|---|---|---|
| committer | Gael Pasgrimaud <gael@gawel.org> | 2013-01-29 13:42:21 +0100 |
| commit | 9b7f30e3ee659ff618e72399d5da63b46b899d13 (patch) | |
| tree | 759eed251d90fa1724f157481b1d7fdc13ab2af0 /docs | |
| parent | 42cde695d85ea362d029063d73e09ddf43139c6a (diff) | |
| download | webtest-9b7f30e3ee659ff618e72399d5da63b46b899d13.tar.gz | |
clean tests. les doctests mess
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/webtest.txt | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/docs/webtest.txt b/docs/webtest.txt index 4391598..95e2936 100644 --- a/docs/webtest.txt +++ b/docs/webtest.txt @@ -14,8 +14,8 @@ must set that up manually in your tests.) >>> from webtest import TestApp >>> from webtest.debugapp import debug_app - >>> app = TestApp(debug_app) - >>> res = app.get('/form.html') + >>> testapp = TestApp(debug_app) + >>> res = testapp.get('/form.html') >>> res.status '200 OK' >>> res.form @@ -209,43 +209,40 @@ Examples: .. code-block:: python - >>> from webtest import TestRequest - >>> from webtest import TestResponse - >>> res = TestResponse(content_type='text/html', body=b''' - ... <html><body><div id="content">hey!</div></body>''') - >>> res.request = TestRequest.blank('/') + >>> res = app.get('/page.html') >>> res.html #doctest: +SKIP <BLANKLINE> <html><body><div id="content">hey!</div></body></html> - >>> res.html.__class__ #doctest: +SKIP - <class 'BeautifulSoup.BeautifulSoup'> + >>> res.html.__class__ + <class '...BeautifulSoup'> + >>> res.lxml <Element html at ...> >>> res.lxml.xpath('//body/div')[0].text 'hey!' - >>> res = TestResponse(content_type='application/json', - ... body=b'{"a":1,"b":2}') - >>> res.request = TestRequest.blank('/') + + >>> res = app.get('/object.json') >>> sorted(res.json.values()) [1, 2] - >>> res = TestResponse(content_type='application/xml', - ... body=b'<xml><message>hey!</message></xml>') - >>> res.request = TestRequest.blank('/') + + >>> res = app.get('/document.xml') >>> res.xml <Element ...> >>> res.xml[0].tag 'message' >>> res.xml[0].text 'hey!' + >>> res.lxml <Element xml at ...> >>> res.lxml[0].tag 'message' >>> res.lxml[0].text 'hey!' - >>> res.pyquery('message') #doctest: +SKIP + + >>> res.pyquery('message') [<message>] - >>> res.pyquery('message').text() #doctest: +SKIP + >>> res.pyquery('message').text() 'hey!' TestResponse API |
