Skip to main content

期望 Tornado 请求和响应对象的匹配器

项目描述

最新版本 PyPI 下载次数 https://secure.travis-ci.org/jaimegildesagredo/tornado-expects.svg?branch=master

Tornado-Expects 是Expects断言库的匹配器库。它为Tornado Web 框架请求和响应对象提供匹配器。

安装

您可以使用pipeasy_install从 PyPI 安装最后一个稳定版本。

$ pip install tornado-expects

您也可以从Github安装最新的源代码。

$ pip install -e git+git://github.com/jaimegildesagredo/tornado-expects.git#egg=tornado-expects

用法

只需导入expect可调用对象和 Tornado-Expects 匹配器,然后开始为测试替身编写断言。

from expects import expect
from tornado_expects import *
from tornado.httpclient import HTTPClient

response = http_client.fetch('https://example.com')

expect(response).to(be_ok)

匹配器

be_ok

expect(response).to(be_ok)
expect(response).not_to(be_ok)

be_json

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))

眼镜

要运行规范,您应该安装测试要求,然后运行​​mamba

$ python setup.py develop
$ pip install -r test-requirements.txt
$ mamba

执照

Tornado-Expects 是在Apache2 许可下发布的。

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

tornado-expects-0.1.0.tar.gz (3.2 kB 查看哈希)

已上传 source