コード例 #1
0
ファイル: unittestpy.py プロジェクト: amaran1988/python3
    def stopTest(self, test):
        test_id = self.get_test_id(test)

        if getattr(self, 'buffer', None):
            # Do not allow super() method to print output by itself
            self._mirrorOutput = False

            output = sys.stdout.getvalue()
            if output:
                for chunk in split_output(limit_output(output)):
                    self.messages.testStdOut(test_id, chunk, flowId=test_id)

            error = sys.stderr.getvalue()
            if error:
                for chunk in split_output(limit_output(error)):
                    self.messages.testStdErr(test_id, chunk, flowId=test_id)

        super(TeamcityTestResult, self).stopTest(test)

        if test_id not in self.failed_tests:
            subtest_failures = self.get_subtest_failure(test_id)
            if subtest_failures:
                self.report_fail(test, "One or more subtests failed", "")

        time_diff = datetime.datetime.now(
        ) - self.test_started_datetime_map[test_id]
        self.messages.testFinished(test_id,
                                   testDuration=time_diff,
                                   flowId=test_id)
コード例 #2
0
    def report_test_output(self, report, test_id):
        for (secname, data) in report.sections:
            if report.when not in secname:
                continue
            if not data:
                continue

            if 'stdout' in secname:
                for chunk in split_output(limit_output(data)):
                    self.teamcity.testStdOut(test_id, out=chunk, flowId=test_id)
            elif 'stderr' in secname:
                for chunk in split_output(limit_output(data)):
                    self.teamcity.testStdErr(test_id, out=chunk, flowId=test_id)
コード例 #3
0
    def report_fail(self, test, fail_type, err):
        # workaround nose bug on python 3
        if is_string(err[1]):
            err = (err[0], Exception(err[1]), err[2])

        test_id = self.get_test_id(test)

        details = convert_error_to_string(err)

        start_index = details.find(_captured_output_start_marker)
        end_index = details.find(_captured_output_end_marker)

        if 0 <= start_index < end_index:
            captured_output = details[start_index +
                                      len(_captured_output_start_marker
                                          ):end_index]
            details = details[:start_index] + details[
                end_index + len(_captured_output_end_marker):]

            for chunk in split_output(limit_output(captured_output)):
                self.messages.testStdOut(test_id, chunk, flowId=test_id)

        self.messages.testFailed(test_id,
                                 message=fail_type,
                                 details=details,
                                 flowId=test_id)
コード例 #4
0
    def report_test_output(self, report, test_id, when):
        for (secname, data) in report.sections:
            if when not in secname:
                continue
            if not data:
                continue

            if 'stdout' in secname:
                for chunk in split_output(limit_output(data)):
                    self.teamcity.testStdOut(test_id,
                                             out=chunk,
                                             flowId=test_id)
            elif 'stderr' in secname:
                for chunk in split_output(limit_output(data)):
                    self.teamcity.testStdErr(test_id,
                                             out=chunk,
                                             flowId=test_id)
コード例 #5
0
ファイル: pytest_plugin.py プロジェクト: amaran1988/python3
    def report_test_output(self, report, test_id):
        for (secname, data) in report.sections:
            # https://github.com/JetBrains/teamcity-messages/issues/112
            # CollectReport doesn't have 'when' property
            if hasattr(report, "when") and report.when not in secname:
                continue
            if not data:
                continue

            if 'stdout' in secname:
                for chunk in split_output(limit_output(data)):
                    self.teamcity.testStdOut(test_id,
                                             out=chunk,
                                             flowId=test_id)
            elif 'stderr' in secname:
                for chunk in split_output(limit_output(data)):
                    self.teamcity.testStdErr(test_id,
                                             out=chunk,
                                             flowId=test_id)
コード例 #6
0
ファイル: nose_report.py プロジェクト: rshah2019/DWH
    def report_finish(self, test):
        test_id = self.get_test_id(test)

        captured_output = getattr(test, "capturedOutput", None)
        if captured_output is None and self._capture_plugin_enabled(test):
            # nose capture does not fill 'capturedOutput' property on successful tests
            captured_output = self._capture_plugin_buffer(test)
        if captured_output:
            for chunk in split_output(limit_output(captured_output)):
                self.messages.testStdOut(test_id, chunk, flowId=test_id)

        if test_id in self.test_started_datetime_map:
            time_diff = datetime.datetime.now() - self.test_started_datetime_map[test_id]
            self.messages.testFinished(test_id, testDuration=time_diff, flowId=test_id)
        else:
            self.messages.testFinished(test_id, flowId=test_id)
コード例 #7
0
ファイル: nose_report.py プロジェクト: lewisc/teamcity-python
    def report_fail(self, test, fail_type, err):
        # workaround nose bug on python 3
        if is_string(err[1]):
            err = (err[0], Exception(err[1]), err[2])

        test_id = self.get_test_id(test)

        details = convert_error_to_string(err)

        start_index = details.find(_captured_output_start_marker)
        end_index = details.find(_captured_output_end_marker)

        if 0 <= start_index < end_index:
            captured_output = details[start_index + len(_captured_output_start_marker):end_index]
            details = details[:start_index] + details[end_index + len(_captured_output_end_marker):]

            for chunk in split_output(limit_output(captured_output)):
                self.messages.testStdOut(test_id, chunk, flowId=test_id)

        self.messages.testFailed(test_id, message=fail_type, details=details, flowId=test_id)