コード例 #1
0
    def _output_summary(self, run_id):
        """Output a test run.

        :param run_id: The run id.
        """
        time = self._summary.get_time_taken()
        time_delta = None
        num_tests_run_delta = None
        num_failures_delta = None
        values = [('id', run_id, None)]
        failures = self._summary.get_num_failures()
        previous_summary = self._get_previous_summary()
        if failures:
            if previous_summary:
                num_failures_delta = failures - \
                    previous_summary.get_num_failures()
            values.append(('failures', failures, num_failures_delta))
        if previous_summary:
            num_tests_run_delta = self._summary.testsRun - \
                previous_summary.testsRun
            if time:
                previous_time_taken = previous_summary.get_time_taken()
                if previous_time_taken:
                    time_delta = time - previous_time_taken
        skips = len(self._summary.skipped)
        if skips:
            values.append(('skips', skips, None))
        output.output_summary(
            not bool(failures), self._summary.testsRun, num_tests_run_delta,
            time, time_delta, values, output=self.stream)
コード例 #2
0
ファイル: test_output.py プロジェクト: mtreinish/stestr
 def test_output_summary_failed(self):
     expected = 'Ran 10 (+5) tests in 1.100s (+0.100s)\n' \
         'FAILED (id=99 (+1), id=100 (+2))\n'
     with io.StringIO() as f:
         output.output_summary(successful=False,
                               tests=10,
                               tests_delta=5,
                               time=1.1,
                               time_delta=0.1,
                               values=[('id', 99, 1), ('id', '100', 2)],
                               output=f)
         actual = f.getvalue()
         self.assertEqual(expected, actual)