mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-24047: Unittest subtest status may be Failure or Error when test failed
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user