Skip to main content

Test WSGI applications

Project description

Flea is a library that helps you write functional tests for WSGI applications.

Flea uses CSS selectors and XPath to give you a simple but powerful tool to navigate and test the HTML responses generated by your WSGI web applications. Here’s an example of how easy it is to test a WSGI application:

>>> r = TestAgent(my_wsgi_app).get('/')
>>> print r.body
<html>
        <body>
                <a href="/sign-in">sign in</a>
        </body>
</html>
>>> r = r.click('sign in')
>>> r = r("form#login-form").fill(
...     username = 'root',
...     password = 'secret',
... ).submit()
>>> assert 'login successful' in r.body

Changes

Version 7.3.4

  • Updated setup.py to require cssselect

Version 7.3.3

  • Included logging facility to allow easy tracing of calls to the application under test

  • Added a flea.testing WSGI environ key so that the AUT can tell when it is running in a test environment

  • Fixed a bug in post_multipart that caused an error when passing a data dict

Version 7.3.2

  • Fixed bug in fill method, which was not clearing checkbox elements

Version 7.3.1

  • Fixed bug in TestAgent.follow

Version 7.3.0

  • New API for form filling, with each control type having a fill method. The value attribute is no longer overloaded.

  • You can now traverse the DOM by calling the TestAgent object directly with either a CSS selector or XPath expression.

  • TestAgent.click() now takes an argument that selects links by their textual content, eg agent.click('view results'). If you want the old behaviour, you need to pass a second argument, eg agent.click('//a[.="view results"]', 'xpath').

Version 7.2.1

  • The value property now does the right thing with respect to checkbox and

    radio groups. For checkbox groups, .value will get/set a list of values corresponding to the selected checkboxes. For radio buttons, .value will get/set the selected radio button.

  • Fixed error following links containing a fragment identifier

Version 7.2.0

  • Added .reload and .new_session methods to TestAgent

Version 7.1.1

  • Fixed check_status argument not being accepted in get, post, click, submit etc methods

Version 7.1.0

  • Added .fill - fill multiple form fields in a single call.

  • Added .show - show the current response in a web browser

  • Added .serve - start an HTTP server for the the application under test and

    open a browser at the current page

  • Added check for HTTP status success or redirect codes (2xx or 3xx),

    anything else raises an AssertionError by default

  • Changed default behaviour to follow HTTP redirects

  • Changed version numbering scheme to <major>.<minor>

Version 7

  • Fixed error when accessing the ‘checked’ property of an input box

  • Prevented raising of ValueError on non-matching xpaths when accessed by

    .find() (__getitem__ will however still raise an error).

Version 6

  • Requires pesto 16 or higher

Version 5

  • Updated setup.py for compatibility with pesto==15

Version 4

  • Added support for file upload fields

  • Allow TestAgent.get/post etc to take a relative URI as an argument

Version 3

  • Updated setup.py for compatibility with pesto==14

Version 2

  • EXSLT regular expression namespace is bound to re prefix by default,

    allowing regexps in xpath expressions.

  • Bug fixes for form element handling

Version 1

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flea-7.3.4.tar.gz (25.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page