PY-24047: Unittest subtest status may be Failure or Error when test failed

This commit is contained in:
Ilya.Kazakevich
2017-05-10 18:29:30 +03:00
parent 932d1215d6
commit 11b93f437d
3 changed files with 36 additions and 1 deletions
+1 -1
View File
@@ -239,7 +239,7 @@ class NewTeamcityServiceMessages(_old_service_messages):
# closing subtest
test_name = ".".join(TREE_MANAGER.current_branch)
if self._latest_subtest_result == "Failure":
if self._latest_subtest_result in set(["Failure", "Error"]):
self.testFailed(test_name)
if self._latest_subtest_result == "Skip":
self.testIgnored(test_name)
@@ -0,0 +1,6 @@
from unittest import TestCase
class TestThis(TestCase):
def test_this(self):
with self.subTest('test'):
raise AttributeError('should fail')
@@ -131,6 +131,35 @@ public final class PythonUnitTestingTest extends PyEnvTestCase {
});
}
// Ensure failed and error subtests work
@Test
@EnvTestTagsRequired(tags = "python3")
public void testSubTestError() throws Exception {
runPythonTest(new PyUnitTestProcessWithConsoleTestTask("testRunner/env/unit/subtestError", "test_test.py") {
@NotNull
@Override
protected PyUnitTestProcessRunner createProcessRunner() throws Exception {
return new PyUnitTestProcessRunner(toFullPath(myScriptName), 0);
}
@Override
protected void checkTestResults(@NotNull final PyUnitTestProcessRunner runner,
@NotNull final String stdout,
@NotNull final String stderr,
@NotNull final String all) {
assertEquals("subtest error reported as success", "Test tree:\n" +
"[root]\n" +
".test_test\n" +
"..TestThis\n" +
"...test_this\n" +
"....[test](-)\n", runner.getFormattedTestTree());
}
});
}
/**
* subtest names may have dots and shall not break test tree
*/