コード例 #1
0
ファイル: middleware_tests.py プロジェクト: bobuss/pynba
        def app(environ, start_response):
            with pynba.timer(foo="bar") as timer:
                status = '200 OK'
                headers = [('Content-type', 'text/plain')]
                start_response(status, headers)

            return ['foo', 'bar']
コード例 #2
0
        def app(environ, start_response):
            with pynba.timer(foo="bar") as timer:
                status = '200 OK'
                headers = [('Content-type', 'text/plain')]
                start_response(status, headers)

            return ['foo', 'bar']
コード例 #3
0
ファイル: test_ctx.py プロジェクト: IsCoolEntertainment/pynba
    def test_context2(self):
        assert not pynba.enabled

        reporter = lambda *x, **y: x
        environ = {}
        with RequestContext(reporter, environ) as ctx:
            assert pynba.enabled
            timer = pynba.timer(foo="bar")
            self.assertIn(timer, pynba.timers)

        ctx.flush()
        with self.assertRaises((RuntimeError, AttributeError)):
            self.assertIn(timer, pynba.timers)

        with ctx:
            ctx.flush()
コード例 #4
0
ファイル: ctx_tests.py プロジェクト: bobuss/pynba
    def test_context2(self):
        with self.assertRaises((RuntimeError, AttributeError)):
            pynba.enabled

        reporter = lambda *x, **y: x
        environ = {}
        with RequestContext(reporter, environ) as ctx:
            timer = pynba.timer(foo='bar')
            self.assertIn(timer, pynba.timers)

        ctx.flush()
        with self.assertRaises((RuntimeError, AttributeError)):
            self.assertIn(timer, pynba.timers)

        with ctx:
            ctx.flush()