diff options
author | ianb <devnull@localhost> | 2005-11-09 06:20:36 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2005-11-09 06:20:36 +0000 |
commit | 26e919896bb5c559205fe3cc85c0ca8f3180d641 (patch) | |
tree | 1ef17d2c6320d8d1495fee460778a4f297680343 /docs/testing-applications.txt | |
parent | d0441ff28d999e1ade91f96ba9f46dc821fc0f2d (diff) | |
download | paste-26e919896bb5c559205fe3cc85c0ca8f3180d641.tar.gz |
Added documentation of some of the new features of paste.fixture
Diffstat (limited to 'docs/testing-applications.txt')
-rw-r--r-- | docs/testing-applications.txt | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/docs/testing-applications.txt b/docs/testing-applications.txt index 8e64c52..af9e111 100644 --- a/docs/testing-applications.txt +++ b/docs/testing-applications.txt @@ -117,6 +117,17 @@ The response object: ``str(res)``: Gives a slightly-compacted version of the response. +``click(description=None, linkid=None, href=None, anchor=None, + index=None, verbose=False)``: Clicks the described link (`see + docstring for more + <./class-paste.fixture.TestResponse.html#click>`_) + +``forms``: + Return a dictionary of forms; you can use both indexes (refer to + the forms in order) or the string ids of forms (if you've given + them ids) to identify the form. See `Form Submissions <#form-submissions>`_ for + more on the form objects. + Request objects: ``url``: @@ -128,17 +139,40 @@ Request objects: ``full_url``: The url with query string. +Form Submissions +================ + +You can fill out and submit forms from your tests. First you get the +form:: + + res = testapp.get('/entry_form') + form = res.forms[0] + +Then you fill it in fields:: + + # when there's one unambiguous name field: + form['name'] = 'Bob' + # Enter something into the first field named 'age' + form.set('age', '45', index=1) + +Finally you submit:: + + # Submit with no particular submit button pressed: + form.submit() + # Or submit a button: + form.submit('submit_button_name') + Framework Hooks =============== Frameworks can detect that they are in a testing environment by the presence (and truth) of the WSGI environmental variable -``"paste.testing"`` (which will be true). +``"paste.testing"``. More generally, frameworks can detect that something (possibly a test fixture) is ready to catch unexpected errors by the presence and truth of ``"paste.throw_errors"`` (this is sometimes set outside of testing -fixtures too, when the error-handling middleware is in place). +fixtures too, when an error-handling middleware is in place). Frameworks that want to expose the inner structure of the request may use ``"paste.testing_variables"``. This will be a dictionary -- any |