Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
65 lines (52 sloc) 1.642 kb
import webtest
import web
urls = (
"/", "index",
"/hello/(.*)", "hello",
"/cookie", "cookie",
"/setcookie", "setcookie",
"/redirect", "redirect",
app = web.application(urls, globals())
class index:
def GET(self):
return "welcome"
class hello:
def GET(self, name):
name = name or 'world'
return "hello, " + name + '!'
class cookie:
def GET(self):
return ",".join(sorted(web.cookies().keys()))
class setcookie:
def GET(self):
i = web.input()
for k, v in i.items():
web.setcookie(k, v)
return "done"
class redirect:
def GET(self):
i = web.input(url='/')
raise web.seeother(i.url)
class BrowserTest(webtest.TestCase):
def testCookies(self):
b = app.browser()'')'')
self.assertEquals(, 'x,y')
def testNotfound(self):
b = app.browser()'')
self.assertEquals(b.status, 404)
def testRedirect(self):
b = app.browser()'')
self.assertEquals(b.url, '')'')
self.assertEquals(b.url, '')'')
self.assertEquals(b.url, '')'')
self.assertEquals(b.url, '')
if __name__ == "__main__":
Jump to Line
Something went wrong with that request. Please try again.