From 519cd800c8d3c04cd645470ce3c19ccf914a6ed7 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Tue, 3 Apr 2018 02:26:08 +0300 Subject: [PATCH] PY-28893: Sync with teamcity-messages +test added Convert objects and message in diff to string --- python/helpers/pycharm/teamcity/diff_tools.py | 6 ++++-- python/helpers/pycharm/teamcity/messages.py | 2 +- .../testRunner/env/unit/testDiff/test_test.py | 4 ++++ .../python/testing/PythonUnitTestingTest.java | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 python/testData/testRunner/env/unit/testDiff/test_test.py diff --git a/python/helpers/pycharm/teamcity/diff_tools.py b/python/helpers/pycharm/teamcity/diff_tools.py index f19fc998b42c..c85f7d492291 100644 --- a/python/helpers/pycharm/teamcity/diff_tools.py +++ b/python/helpers/pycharm/teamcity/diff_tools.py @@ -2,6 +2,8 @@ import pprint import sys import unittest +from .messages import text_type + _PY2K = sys.version_info < (3,) _PRIMITIVES = [int, str, bool] if _PY2K: @@ -52,12 +54,12 @@ class EqualsAssertionError(AssertionError): super(AssertionError, self).__init__() self.expected = expected self.actual = actual - self.msg = msg + self.msg = text_type(msg) if not preformated: self.expected = _format_and_convert(self.expected) self.actual = _format_and_convert(self.actual) - self.msg = msg if msg else "" + self.msg = text_type(msg) if msg else "" self.expected = _STR_F(self.expected) self.actual = _STR_F(self.actual) diff --git a/python/helpers/pycharm/teamcity/messages.py b/python/helpers/pycharm/teamcity/messages.py index 6e8978e682ca..a19bd8f215b9 100644 --- a/python/helpers/pycharm/teamcity/messages.py +++ b/python/helpers/pycharm/teamcity/messages.py @@ -152,7 +152,7 @@ class TeamcityServiceMessages(object): diff_message = u"\n{0} != {1}\n".format(comparison_failure.actual, comparison_failure.expected) self.message('testFailed', name=testName, - message=message + text_type(diff_message), + message=text_type(message) + text_type(diff_message), details=details, flowId=flowId, type="comparisonFailure", diff --git a/python/testData/testRunner/env/unit/testDiff/test_test.py b/python/testData/testRunner/env/unit/testDiff/test_test.py new file mode 100644 index 000000000000..b923e29ebd15 --- /dev/null +++ b/python/testData/testRunner/env/unit/testDiff/test_test.py @@ -0,0 +1,4 @@ +import unittest +class MyTestCase(unittest.TestCase): + def test_case(self): + self.assertEqual(1, 2, ('a', 'tuple')) \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java b/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java index f91295726460..4ba6c95231be 100644 --- a/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java +++ b/python/testSrc/com/jetbrains/env/python/testing/PythonUnitTestingTest.java @@ -35,8 +35,10 @@ import com.jetbrains.python.testing.PyUnitTestConfiguration; import com.jetbrains.python.testing.PyUnitTestFactory; import com.jetbrains.python.testing.PythonTestConfigurationsModel; import com.jetbrains.python.tools.sdkTools.SdkCreationType; +import org.hamcrest.Matchers; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Assert; import org.junit.Test; import java.io.IOException; @@ -138,6 +140,21 @@ public final class PythonUnitTestingTest extends PythonUnitTestingLikeTest