Ejemplo n.º 1
0
    def test_timing_contextmanager_with_explicit_request_object(self):
        def viewit(request):
            with metrics_timer("timer1", request):
                time.sleep(0.01)

        request = Request.blank("/")
        initialize_request_metrics(request)
        viewit(request)

        ts = request.metrics["timer1"]
        self.assertTrue(0.01 < ts < 0.1)
Ejemplo n.º 2
0
    def test_timing_contextmanager(self):
        def viewit(request):
            with metrics_timer("timer1"):
                time.sleep(0.01)

        request = Request.blank("/")
        initialize_request_metrics(request)
        with pyramid.testing.testConfig(request=request):
            viewit(request)

        ts = request.metrics["timer1"]
        self.assertTrue(0.01 < ts < 0.1)
Ejemplo n.º 3
0
    def test_timing_contextmanager_with_explicit_request_object(self):

        def viewit(request):
            with metrics_timer("timer1", request):
                time.sleep(0.01)

        request = Request.blank("/")
        initialize_request_metrics(request)
        viewit(request)

        ts = request.metrics["timer1"]
        self.assertTrue(0.01 < ts < 0.1)
Ejemplo n.º 4
0
    def test_timing_contextmanager(self):

        def viewit(request):
            with metrics_timer("timer1"):
                time.sleep(0.01)

        request = Request.blank("/")
        initialize_request_metrics(request)
        with pyramid.testing.testConfig(request=request):
            viewit(request)

        ts = request.metrics["timer1"]
        self.assertTrue(0.01 < ts < 0.1)
Ejemplo n.º 5
0
    def test_timing_decorator(self):
        @metrics_timer("timer1")
        def doit1():
            time.sleep(0.01)

        def viewit(request):
            doit1()

        request = Request.blank("/")
        initialize_request_metrics(request)
        with pyramid.testing.testConfig(request=request):
            viewit(request)

        ts = request.metrics["timer1"]
        self.assertTrue(0.01 < ts < 0.1)
Ejemplo n.º 6
0
    def test_timing_decorator(self):

        @metrics_timer("timer1")
        def doit1():
            time.sleep(0.01)

        def viewit(request):
            doit1()

        request = Request.blank("/")
        initialize_request_metrics(request)
        with pyramid.testing.testConfig(request=request):
            viewit(request)

        ts = request.metrics["timer1"]
        self.assertTrue(0.01 < ts < 0.1)