将在单独线程中为您启动wsgi/werkzeug应用程序的测试用例

wsgitestcase的Python项目详细描述


Version:0.1
https://travis-ci.org/bak1an/wsgitestcase.png?branch=master

将在单独线程中启动wsgi/werkzeug应用程序的测试用例 为您(使用setupteardown方法)。

灵感来源于Django的LiveServerTestCase。

如何

importrequests# you should use this, requests is coolfromwsgitestcaseimportWsgiTestCaseclassMyTestCase(WsgiTestCase):# add your wsgi application here# you can also set it with something like# app = staticmethod(my_wsgi_app)# see tests.py for more examples@staticmethoddefapp(environ,start_response):start_response('200 OK',[('Content-Type','text/plain')])yield'Hello World'deftest_something(self):# server with your app should be already up# use self.host, self.port and self.url to find out where it isr=requests.get("http://%s:%s/"%(self.host,self.port))self.assertEqual(r.text,"Hello World")# in self.requests you can find a list with all requests made to# your app. it contains werkzeug's Request objects.# see tests.py for more examples# and werkzeug's doc at http://werkzeug.pocoo.org/docs/wrappers/# for Request object referenceself.assertEqual(len(self.requests),1)self.assertEqual(self.requests[0].path,"/")

许可证

wsgitestcase是根据mit许可条款发布的。

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

推荐PyPI第三方库


热门话题
java Android同步不同页面上的按钮   java评测每个类收集的垃圾对象实例数   java(Spring MVC+Hibernate 4+Test 4)自动连线DAO返回NULL   java Android编辑文本和虚拟键盘   java Selenium与BrowserMobProxy   JAVAlang.NoClassDefFoundError:com/sun/jersey/spi/inject/Errors$关闭原因?   java为什么在我成功登录后仍然会出现“不正确的帐户或密码或用户类型”   安卓应用程序在重新启动java时崩溃。网UnknownHostException:无法解析主机   多线程在Java中同步共享静态对象的正确方法是什么?   未调用自定义注释的java类验证(约束类)   java如何将指定目录的存档文件放入所需位置?   java如何识别Selenium中的每个编辑文本字段,如果它们的Xpath都相同   使用gwtmockito/mockito的java简单单选按钮单元测试?