python wrapper&utils,用于通过wire-test-double工具进行mountebank。

mbtest的Python项目详细描述


mbtest

用于Mountebankover the wire test double工具的自以为是的python包装器和实用程序。

包括pytest夹具和PyHamcrest匹配器。

made-with-pythonBuild StatusPyPi VersionPython VersionsLicenceGitHub all releasesGitHub forksGitHub starsGitHub watchersGitHub contributorsGitHub issuesGitHub issues-closedGitHub pull-requestsGitHub pull-requests closedCodacy BadgeCodacy CoverageLines of Code

设置

使用pip安装:

pip install mbtest

(与往常一样,建议使用venvvirtualenv。)还需要安装Mountebank

npm install mountebank@1.16 --production

基本示例

importrequestsfromhamcrestimportassert_that,is_frombrunns.matchers.responseimportresponse_withfrommbtest.matchersimporthad_requestfrommbtest.impostersimportImposter,Predicate,Response,Stubdeftest_request_to_mock_server(mock_server):# Set up mock server with required behaviorimposter=Imposter(Stub(Predicate(path="/test"),Response(body="sausages")))withmock_server(imposter)asserver:# Make request to mock server - exercise code under test hereresponse=requests.get("{}/test".format(imposter.url))assert_that("We got the expected response",response,is_(response_with(status_code=200,body="sausages")))assert_that("The mock server recorded the request",server,had_request(path="/test",method="GET"))

需要一个pytest fixture,最容易在^{}中定义:

importpytestfrommbtestimportserver@pytest.fixture(scope="session")defmock_server(request):returnserver.mock_server(request)

更复杂谓词的示例可以在integration tests中找到。

开发

需要maketox。runmake precommit告诉您是否可以提交。有关更多选项,请运行:

make help

释放

需要hubsetuptoolstwine。释放n.n.n

version="n.n.n" # Needs to match new version number in setup.py.
make precommit && git commit -am"Release $version" && git push # If not already all pushed, which it should be.
hub release create $version -m"Release $version"
python setup.py sdist bdist_wheel
twine upload dist/*$version*

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在reducer中迭代自定义可写组件时出现java问题   属性文件中属性的java命名约定   任务链关闭的java Executor服务   java从Eclipse中的字段生成多个构造函数   java通过继承读取Json   java在不知道密钥的情况下解析json   java camel cxf如何在电子邮件中发送soap请求响应   java程序似乎跳过了if语句的一部分,在移回正确位置之前先移到else语句   测试简单的Java加密/解密inputFileName不存在   java从Jenkins REST API获取所有作业的所有构建的构建细节   java基本包装器和静态“类型”类对象   在WebSphere8.5上部署java代码   java对象相等(对象引用“=”)   java MongoDB整型字段到枚举的转换   每次我重新导入gradle时,IntelliJ都会不断重置Java设置   类型使用键或索引从Java中的数据类型检索值   在Java的列表接口中需要listIterator()和iterator()是什么?