MCPcopy Index your code
hub / github.com/webpy/webpy / test_subdirs

Method test_subdirs

tests/test_application.py:139–168  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

137 self.assertEqual(app.request("/foo").data, b"foo")
138
139 def test_subdirs(self):
140 urls = ("/(.*)", "blog")
141
142 class blog:
143 def GET(self, path):
144 return "blog " + path
145
146 app_blog = web.application(urls, locals())
147
148 # fmt: off
149 urls = (
150 "/blog", app_blog,
151 "/(.*)", "index"
152 )
153 # fmt: on
154
155 class index:
156 def GET(self, path):
157 return "hello " + path
158
159 app = web.application(urls, locals())
160
161 self.assertEqual(app.request("/blog/foo").data, b"blog foo")
162 self.assertEqual(app.request("/foo").data, b"hello foo")
163
164 def processor(handler):
165 return web.ctx.path + ":" + handler()
166
167 app.add_processor(processor)
168 self.assertEqual(app.request("/blog/foo").data, b"/blog/foo:blog foo")
169
170 def test_subdomains(self):
171 def create_app(name):

Callers

nothing calls this directly

Calls 2

requestMethod · 0.80
add_processorMethod · 0.80

Tested by

no test coverage detected