期望匹配龙卷风请求和响应对象
tornado-expects的Python项目详细描述
tornado expects是Expects断言库的匹配器库。它为Tornado web framework请求和响应对象提供匹配器。
安装
您可以使用pip或easy_install安装pypi的最后一个稳定版本。
$ pip install tornado-expects
您还可以从github安装最新的源代码。
$ pip install -e git+git://github.com/jaimegildesagredo/tornado-expects.git#egg=tornado-expects
用法
只要导入expectcallable,tornado就需要匹配器,并开始为测试double编写断言。
fromexpectsimportexpectfromtornado_expectsimport*fromtornado.httpclientimportHTTPClientresponse=http_client.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'))
有u头
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))
规格
要运行规范,您应该安装测试需求,然后运行mamba。
$ python setup.py develop $ pip install -r test-requirements.txt $ mamba
许可证
龙卷风预计在{a6}下释放。