def application(self, environ=None): app = self.app ctx = local.push(app, environ) try: if environ is not None: ctx.request = app.config['ayame.request'](environ, {}) ctx._router = app.config['ayame.route.map'].bind(environ) yield finally: local.pop()
def test_push(self): ctx = local.push(0, 1) self.assert_equal(ctx.app, 0) self.assert_equal(ctx.environ, 1) self.assert_is_none(ctx.request) self.assert_is_none(ctx._router) self.assert_is(local.context(), ctx) self.assert_is(local.app(), ctx.app) self.assert_is(local.pop(), ctx) self.assert_is_none(local.pop()) with self.assert_raises(ayame.AyameError): local.context() with self.assert_raises(ayame.AyameError): local.app()