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: 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", "") 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)
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: 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", "") 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)
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: dump_test_stdout(self.teamcity, test_id, test_id, data) elif 'stderr' in secname: dump_test_stderr(self.teamcity, test_id, test_id, data)
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(): # nose capture does not fill 'capturedOutput' property on successful tests captured_output = self._capture_plugin_buffer() if captured_output: dump_test_stdout(self.messages, test_id, test_id, captured_output) 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)
def newCaptureBeforeTest(test): old_before_test(test) test_id = self.get_test_id(test) capture_plugin._buf = FlushingStringIO( lambda data: dump_test_stdout(self.messages, test_id, test_id, data)) sys.stdout = capture_plugin._buf
def _dump_test_stdout(self, data): if self.current_test_id is not None: dump_test_stdout(self.messages, self.current_test_id, self.current_test_id, data) else: _real_stdout.write(data)
def newCaptureBeforeTest(test): rv = old_before_test(test) test_id = self.get_test_id(test) capture_plugin._buf = FlushingStringIO(lambda data: dump_test_stdout(self.messages, test_id, test_id, data)) sys.stdout = capture_plugin._buf return rv