python的testsupport实用程序模块
quiltz-testsupport的Python项目详细描述
quiltz测试支持
测试支持包
目的
在QWAN,我们正在用python构建一些应用程序。我们用棉絮包装收集有用的东西:
- quiltz域 包含域级模块,如实体id、结果、电子邮件匿名器、验证器和解析器
- quiltz测试支持 包含测试支持模块,主要支持非单元测试,如与smtp集成、探测异步结果和断言日志语句
- quiltz消息 包含消息传递域概念和用于发送消息的引擎。目前只支持smtp发送。在
此软件包中的模块
日志
使用日志模块,您可以使用log_collector fixture在测试中断言日志语句:
测试中:
fromquiltz.testsupportimportlog_collectordeftest_logs_hello(log_collector):foo()log_collector.assert_info('hello info')
正在生产中
^{pr2}$探测
使用探测模块,您可以探测异步结果:
fromhamcrestimportassert_that,equal_tofromquiltz.testsupportimportprobe_thatdeftest_stub_server_collects_message_for_recepient(self):message=aMessage(recipient='rob@mailinator.com',sender='no-reply@qwan.eu',subject='test',body='hello test')self.message_engine.send([message])probe_that(lambda:assert_that(self.server.messages,equal_to([stringified_message(message)])))
smtp
使用smtp模块,您可以创建一个收集smtp消息的存根smtp服务器
fromhamcrestimportassert_that,equal_tofromquiltz.testsupportimportprobe_thatdefserver()server=StubSmtpServer(hostname='localhost',port=9925)server.start()yield(server)server.stop()deftest_collects_message_for_recepient(self,server):message_engine=SMTPClientForTest(host='localhost',port='9925')message=aMessage(recipient='rob@mailinator.com',sender='no-reply@qwan.eu',subject='test',body='hello test')message_engine.send([message])probe_that(lambda:assert_that(server.messages,equal_to([stringified_message(message)])))
安装
pip install quiltz-testsupport
- 项目
标签: