Пример #1
0
 def emit(self, record):
     """Emit a record as an OOPS."""
     try:
         info = record.exc_info
         if info is None:
             info = sys.exc_info()
         msg = record.getMessage()
         with globalErrorUtility.oopsMessage(msg):
             globalErrorUtility.raising(info, self.request)
             if self.logger:
                 self.logger.info(self.request.oopsid)
     except Exception:
         self.handleError(record)
Пример #2
0
 def emit(self, record):
     """Emit a record as an OOPS."""
     try:
         info = record.exc_info
         if info is None:
             info = sys.exc_info()
         msg = record.getMessage()
         with globalErrorUtility.oopsMessage(msg):
             globalErrorUtility.raising(info, self.request)
             if self.logger:
                 self.logger.info(self.request.oopsid)
     except Exception:
         self.handleError(record)
Пример #3
0
    def test_get_features_into_oops(self):
        with FeatureFixture({'feature_name': 'value'}):
            with CaptureOops() as capture:
                request = LaunchpadTestRequest()

                self.assertEqual(getFeatureFlag('feature_name'), 'value')

                # Simulate an oops here.
                globalErrorUtility.raising(None, request=request)

                oops = capture.oopses[0]
                self.assertTrue('features.usedScopes' in oops)
                self.assertTrue('features.usedFlags' in oops)
                self.assertEqual(oops['features.usedFlags'],
                                 u"{'feature_name': u'value'}")
Пример #4
0
    def test_get_features_into_oops(self):
        with FeatureFixture({'feature_name': 'value'}):
            with CaptureOops() as capture:
                request = LaunchpadTestRequest()

                self.assertEquals(getFeatureFlag('feature_name'), 'value')

                # Simulate an oops here.
                globalErrorUtility.raising(None, request=request)

                oops = capture.oopses[0]
                self.assertTrue('features.usedScopes' in oops)
                self.assertTrue('features.usedFlags' in oops)
                self.assertEquals(oops['features.usedFlags'],
                    u"{'feature_name': u'value'}")
Пример #5
0
 def test_subscribes_to_events(self):
     capture = self.useFixture(CaptureOops())
     publisher = globalErrorUtility._oops_config.publisher
     try:
         globalErrorUtility._oops_config.publisher = notify_publisher
         id = globalErrorUtility.raising(sys.exc_info())['id']
         self.assertEqual(id, capture.oopses[0]['id'])
         self.assertEqual(1, len(capture.oopses))
     finally:
         globalErrorUtility._oops_config.publisher = publisher
Пример #6
0
 def test_subscribes_to_events(self):
     capture = self.useFixture(CaptureOops())
     publishers = globalErrorUtility._oops_config.publishers[:]
     try:
         globalErrorUtility._oops_config.publishers[:] = [notify_publisher]
         id = globalErrorUtility.raising(sys.exc_info())['id']
         self.assertEqual(id, capture.oopses[0]['id'])
         self.assertEqual(1, len(capture.oopses))
     finally:
         globalErrorUtility._oops_config.publishers[:] = publishers