Exemple #1
0
    def test_actually_reports(self):
        class RootController(TGController):
            @expose()
            def index(self):
                # Wait for the slow req reporter to report the request.
                for i in range(100):
                    if 'request' in REPORTED_CONTEXT:
                        break
                    time.sleep(0.01)
                else:
                    assert False, 'Timeout!'
                return 'HI'

        REPORTED_CONTEXT = {}
        class Reporter(object):
            def report(self, traceback):
                REPORTED_CONTEXT.update(traceback.context)

        cfg = FullStackApplicationConfigurator()
        cfg.update_blueprint({
            'debug': False,
            'trace_slowreqs.enable': True,
            'trace_slowreqs.interval': 0,
            'trace_slowreqs.reporters': [
                Reporter()
            ],
            'root_controller': RootController()
        })
        app = TestApp(cfg.make_wsgi_app({}, {}))
        assert app.get('/').text == 'HI'
        assert 'request' in REPORTED_CONTEXT
Exemple #2
0
    def test_actually_reports(self):
        class RootController(TGController):
            @expose()
            def index(self):
                return 1 / 0

        REPORTED_CONTEXT = {}

        class Reporter(object):
            def report(self, traceback):
                REPORTED_CONTEXT.update(traceback.context)

        cfg = FullStackApplicationConfigurator()
        cfg.update_blueprint({
            'debug': False,
            'trace_errors.enable': True,
            'trace_errors.reporters': [Reporter()],
            'root_controller': RootController()
        })
        app = TestApp(cfg.make_wsgi_app({}, {}))
        app.get('/', status=404)

        assert 'request' in REPORTED_CONTEXT
Exemple #3
0
    def test_actually_reports(self):
        class RootController(TGController):
            @expose()
            def index(self):
                return 1/0

        REPORTED_CONTEXT = {}
        class Reporter(object):
            def report(self, traceback):
                REPORTED_CONTEXT.update(traceback.context)

        cfg = FullStackApplicationConfigurator()
        cfg.update_blueprint({
            'debug': False,
            'trace_errors.enable': True,
            'trace_errors.reporters': [
                Reporter()
            ],
            'root_controller': RootController()
        })
        app = TestApp(cfg.make_wsgi_app({}, {}))
        app.get('/', status=404)

        assert 'request' in REPORTED_CONTEXT