mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
PY-27286: Sync with teamcity-messages + test
This commit is contained in:
@@ -98,20 +98,21 @@ class TeamcityReport(Plugin):
|
||||
old_format_error = capture_plugin.formatError
|
||||
|
||||
def newCaptureBeforeTest(test):
|
||||
old_before_test(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
|
||||
|
||||
def newCaptureAfterTest(test):
|
||||
if isinstance(capture_plugin._buf, FlushingStringIO):
|
||||
capture_plugin._buf.flush()
|
||||
old_after_test(test)
|
||||
return old_after_test(test)
|
||||
|
||||
def newCaptureFormatError(test, err):
|
||||
if isinstance(capture_plugin._buf, FlushingStringIO):
|
||||
capture_plugin._buf.flush()
|
||||
old_format_error(test, err)
|
||||
return old_format_error(test, err)
|
||||
|
||||
capture_plugin.beforeTest = newCaptureBeforeTest
|
||||
capture_plugin.afterTest = newCaptureAfterTest
|
||||
@@ -145,6 +146,12 @@ class TeamcityReport(Plugin):
|
||||
else:
|
||||
return 'true'
|
||||
|
||||
def report_started(self, test):
|
||||
test_id = self.get_test_id(test)
|
||||
|
||||
self.test_started_datetime_map[test_id] = datetime.datetime.now()
|
||||
self.messages.testStarted(test_id, captureStandardOutput=self._captureStandardOutput_value(), flowId=test_id)
|
||||
|
||||
def report_fail(self, test, fail_type, err):
|
||||
# workaround nose bug on python 3
|
||||
if is_string(err[1]):
|
||||
@@ -233,6 +240,10 @@ class TeamcityReport(Plugin):
|
||||
self.report_fail(test, 'error in ' + test.error_context + ' context', err)
|
||||
self.messages.testFinished(test_id, flowId=test_id)
|
||||
else:
|
||||
# some test cases may report errors in pre setup when startTest was not called yet
|
||||
# example: https://github.com/JetBrains/teamcity-messages/issues/153
|
||||
if test_id not in self.test_started_datetime_map:
|
||||
self.report_started(test)
|
||||
self.report_fail(test, 'Error', err)
|
||||
self.report_finish(test)
|
||||
|
||||
|
||||
8
python/testData/testRunner/env/nose/exception_and_log.py
vendored
Normal file
8
python/testData/testRunner/env/nose/exception_and_log.py
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# coding=utf-8
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
def test_test():
|
||||
logging.info('eggs')
|
||||
raise Exception(u"vse ploho")
|
||||
@@ -236,6 +236,28 @@ public final class PythonNoseTestingTest extends PyEnvTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExceptionAndLog() {
|
||||
runPythonTest(new PyProcessWithConsoleTestTask<PyNoseTestProcessRunner>("/testRunner/env/nose", SdkCreationType.EMPTY_SDK) {
|
||||
@NotNull
|
||||
@Override
|
||||
protected PyNoseTestProcessRunner createProcessRunner() {
|
||||
return new PyNoseTestProcessRunner("exception_and_log.py", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkTestResults(@NotNull final PyNoseTestProcessRunner runner,
|
||||
@NotNull final String stdout,
|
||||
@NotNull final String stderr,
|
||||
@NotNull final String all) {
|
||||
assertEquals(1, runner.getAllTestsCount());
|
||||
assertEquals(0, runner.getPassedTestsCount());
|
||||
assertEquals(1, runner.getFailedTestsCount());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class SlowRunnerTask extends PyProcessWithConsoleTestTask<PyNoseTestProcessRunner> {
|
||||
@NotNull
|
||||
private final String myArguments;
|
||||
|
||||
Reference in New Issue
Block a user