Example #1
0
    def format(self, record):
        message = {'message': record.getMessage(),
                   'asctime': self.formatTime(record, self.datefmt),
                   'name': record.name,
                   'msg': record.msg,
                   'args': record.args,
                   'levelname': record.levelname,
                   'levelno': record.levelno,
                   'pathname': record.pathname,
                   'filename': record.filename,
                   'module': record.module,
                   'lineno': record.lineno,
                   'funcname': record.funcName,
                   'created': record.created,
                   'msecs': record.msecs,
                   'relative_created': record.relativeCreated,
                   'thread': record.thread,
                   'thread_name': record.threadName,
                   'process_name': record.processName,
                   'process': record.process,
                   'traceback': None}

        if hasattr(record, 'extra'):
            message['extra'] = record.extra

        if record.exc_info:
            message['traceback'] = self.formatException(record.exc_info)

        return jsonutils.dumps(message)
Example #2
0
    def format(self, record):
        message = {
            'message': record.getMessage(),
            'asctime': self.formatTime(record, self.datefmt),
            'name': record.name,
            'msg': record.msg,
            'args': record.args,
            'levelname': record.levelname,
            'levelno': record.levelno,
            'pathname': record.pathname,
            'filename': record.filename,
            'module': record.module,
            'lineno': record.lineno,
            'funcname': record.funcName,
            'created': record.created,
            'msecs': record.msecs,
            'relative_created': record.relativeCreated,
            'thread': record.thread,
            'thread_name': record.threadName,
            'process_name': record.processName,
            'process': record.process,
            'traceback': None
        }

        if hasattr(record, 'extra'):
            message['extra'] = record.extra

        if record.exc_info:
            message['traceback'] = self.formatException(record.exc_info)

        return jsonutils.dumps(message)
Example #3
0
    def test__save_results_with_log_file(self, mock_isfile):
        with mock.patch.object(subunit2json, 'main') as mock_main:
            data = {'total': True, 'test_cases': True}
            mock_main.return_value = jsonutils.dumps(data)
            self.verifier.log_file_raw = os.path.join(
                os.path.dirname(__file__), 'subunit.stream')
            self.verifier._save_results()
            mock_isfile.assert_called_once_with(self.verifier.log_file_raw)
            mock_main.assert_called_once_with(self.verifier.log_file_raw)

            self.assertEqual(
                1, self.verifier.verification.finish_verification.call_count)
Example #4
0
 def stopTestRun(self):
     super(JsonOutput, self).stopTestRun()
     self.stopTime = datetime.datetime.now()
     total_count = (self.success_count + self.failure_count +
                    self.error_count + self.skip_count)
     total = {"tests": total_count, "errors": self.error_count,
              "skipped": self.skip_count, "success": self.success_count,
              "failures": self.failure_count, "time": self.total_time}
     if self.results_file:
         with open(self.results_file, 'wb') as results_file:
             output = jsonutils.dumps({'total': total,
                                       'test_cases': self.test_cases})
             results_file.write(output)
Example #5
0
    def test__save_results_with_log_file(self, mock_isfile):
        with mock.patch.object(subunit2json, 'main') as mock_main:
            data = {'total': True, 'test_cases': True}
            mock_main.return_value = jsonutils.dumps(data)
            self.verifier.log_file_raw = os.path.join(
                                            os.path.dirname(__file__),
                                            'subunit.stream')
            self.verifier._save_results()
            mock_isfile.assert_called_once_with(self.verifier.log_file_raw)
            mock_main.assert_called_once_with(
                self.verifier.log_file_raw)

            self.assertEqual(
                1, self.verifier.verification.finish_verification.call_count)
Example #6
0
 def stopTestRun(self):
     super(JsonOutput, self).stopTestRun()
     self.stopTime = datetime.datetime.now()
     total_count = (self.success_count + self.failure_count +
                    self.error_count + self.skip_count)
     total = {
         "tests": total_count,
         "errors": self.error_count,
         "skipped": self.skip_count,
         "success": self.success_count,
         "failures": self.failure_count,
         "time": self.total_time
     }
     if self.results_file:
         with open(self.results_file, 'wb') as results_file:
             output = jsonutils.dumps({
                 'total': total,
                 'test_cases': self.test_cases
             })
             results_file.write(output)