def stopTest()

in teamcity/unittestpy.py [0:0]


    def stopTest(self, test):
        test_id = self.get_test_id_with_description(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:
                dump_test_stdout(self.messages, test_id, test_id, output)

            error = sys.stderr.getvalue()
            if error:
                dump_test_stderr(self.messages, test_id, test_id, error)

        super(TeamcityTestResult, self).stopTest(test)

        self.current_test_id = None

        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", "")

        if sys.exc_info()[0] is not None:
            # test was interrupted (e.g., SIGINT)
            self.messages.testStopped(test_id, flowId=test_id)

        try:
            time_diff = datetime.datetime.now() - self.test_started_datetime_map[test_id]
        except KeyError:
            time_diff = None
        self.messages.testFinished(test_id, testDuration=time_diff, flowId=test_id)