Tornado-Expects is a matchers library for the Expects assertion library. It provides matchers for the Tornado web framework request and response objects.
You can install the last stable release from PyPI using pip or easy_install.
$ pip install tornado-expects
Also you can install the latest sources from Github.
$ pip install -e git+git://github.com/jaimegildesagredo/tornado-expects.git#egg=tornado-expects
Just import the expect
callable and the Tornado-Expects matchers and start writing assertions.
from expects import expect
from tornado_expects import *
from tornado.httpclient import HTTPClient
response = HTTPClient().fetch('https://example.com')
expect(response).to(be_ok)
expect(response).to(be_ok)
expect(response).not_to(be_ok)
expect(response).to(be_json)
expect(response).not_to(be_json)
expect(response).to(have_header('Content-Type'))
expect(response).to(have_header('Content-Type', 'text/xml'))
expect(response).to(have_header('Content-Type', start_with('text/xml')))
expect(response).not_to(have_header('ETag'))
expect(response).to(have_headers('Content-Type', 'Content-Length'))
expect(response).to(have_headers({'Content-Type': 'text/html'}))
expect(response).not_to(have_headers('Etag', 'Authorization'))
expect(response).to(have_status(304))
expect(response).not_to(have_status(500))
To run the specs you should install the testing requirements and then run mamba
.
$ python setup.py develop
$ pip install -r test-requirements.txt
$ mamba
The Tornado-Expects is released under the Apache2 license.