diff --git a/python/helpers/pycharm/_jb_runner_tools.py b/python/helpers/pycharm/_jb_runner_tools.py index f05f4b314575..cce7cc6190a6 100644 --- a/python/helpers/pycharm/_jb_runner_tools.py +++ b/python/helpers/pycharm/_jb_runner_tools.py @@ -218,6 +218,20 @@ class NewTeamcityServiceMessages(_old_service_messages): self.testFinished(test_name) self._latest_subtest_result = None + + def testIgnored(self, testName, message='', flowId=None): + import re + # Skipped subtest of unittest in format "test_name.test_name (subtestInfo)" should be processed as special case: + # start, ignore like test_name.test_name.(subtestInfo), stop + match_result = re.match(r"^([^(]+\s)*([(][^)]+[)])$", str(testName)) + if match_result: + test_to_skip = ".".join(TREE_MANAGER.current_branch + [match_result.group(2)]) + self.testStarted(test_to_skip) + super(NewTeamcityServiceMessages, self).testIgnored(test_to_skip, message, flowId) + self.testFinished(test_to_skip) + else: + super(NewTeamcityServiceMessages, self).testIgnored(testName, message, flowId) # For all other cases leave same behaviour + def subTestBlockOpened(self, name, subTestResult, flowId=None): self.testStarted(".".join(TREE_MANAGER.current_branch + [name])) self._latest_subtest_result = subTestResult diff --git a/python/testData/testRunner/env/unit/test_skipped_subtest.py b/python/testData/testRunner/env/unit/test_skipped_subtest.py new file mode 100644 index 000000000000..21ac9d53a14d --- /dev/null +++ b/python/testData/testRunner/env/unit/test_skipped_subtest.py @@ -0,0 +1,21 @@ +import unittest + + +class SampleTest(unittest.TestCase): + widget = None + + def setUp(self): + self.widget = 'abcd' + + def tearDown(self): + self.widget = None + + def test_foo(self): + for i in range(20): + with self.subTest(i=i): + if i % 2: + self.assertTrue(False) + elif not (i % 5): + self.skipTest('it happen') + else: + self.assertEqual(self.widget, 'abcd') \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/env/PyAbstractTestProcessRunner.java b/python/testSrc/com/jetbrains/env/PyAbstractTestProcessRunner.java index 697bcca15a51..23179676c8d1 100644 --- a/python/testSrc/com/jetbrains/env/PyAbstractTestProcessRunner.java +++ b/python/testSrc/com/jetbrains/env/PyAbstractTestProcessRunner.java @@ -142,7 +142,7 @@ public class PyAbstractTestProcessRunner