Trio的假设插件

hypothesis-trio的Python项目详细描述


https://travis-ci.org/python-trio/hypothesis-trio.svg?branch=masterhttps://codecov.io/gh/python-trio/hypothesis-trio/branch/master/graph/badge.svg

欢迎来到hypothesis-trio

假设支持非状态测试的开箱即用trio。 此项目旨在支持状态模式;-)

许可证:您可以选择MIT或Apache许可证2.0

用法

hypothesis.stateful.RuleBasedStateMachine替换为hypothesis_trio.stateful.TrioRuleBasedStateMachine

fromhypothesis_trio.statefulimportTrioRuleBasedStateMachine,run_state_machine_as_testdeftest_trio_number_modifier(hypothesis_settings):classNumberModifier(TrioRuleBasedStateMachine):folders=Bundle('folders')files=Bundle('files')@initialize(target=folders)asyncdefinit_folders(self):awaittrio.sleep(0)return'/'@rule(target=folders,name=name_strategy)asyncdefcreate_folder(self,parent,name):awaittrio.sleep(0)return'%s/%s'%(parent,name)@rule(target=files,name=name_strategy)asyncdefcreate_file(self,parent,name):awaittrio.sleep(0)return'%s/%s'%(parent,name)asyncdefteardown(self):awaittrio.sleep(0)run_state_machine_as_test(NumberModifier,settings=hypothesis_settings)

支持Trio Asyncio

trio-asyncio允许将异步代码和三元代码混合在一起。 要在测试中支持它,您应该使用hypothesis_trio.stateful.TrioAsyncioRuleBasedStateMachine

classCheckAsyncioLoop(TrioAsyncioRuleBasedStateMachine):@initialize()asyncdefinitialize(self):assertself.get_asyncio_loop()==asyncio.get_event_loop()awaittrio_asyncio.aio_as_trio(lambda:asyncio.sleep(0))

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

推荐PyPI第三方库


热门话题
java为什么这段代码要打印空字符串?   java未知错误:由于标签页崩溃,会话被删除   布尔型上的java函数if-else   java最佳蚂蚁教程/快速入门?   JAVAutil。java中的扫描程序跳过do while循环中的扫描程序输入   java我们可以在selenium中使用ExpectedConditions和FluentWait来实现通用等待方法吗?   java如何使用gson库解析JSONObject   java GWT模拟Android LinearLayout的布局重量属性?   Java正则表达式重写日期表达式   java MediaPlayer播放我的MP3文件,但非常安静   java背景不显示javaFX   用于CLI的java quarkus开发模式,如何重新启动应用程序   websphere WSJdbcDataSource的java Jar文件   java Spring 4对象不会自动连接变量   java从Dbpedia定制本体/RDF图