From 2c369762dbc0c64897bcf8ee5335847eae2a5366 Mon Sep 17 00:00:00 2001 From: Roman Chernyatchik Date: Tue, 1 Feb 2011 13:33:49 +0300 Subject: [PATCH] pycharm: unescape "\n" in expected/actual texts provided by test unit framework --- python/helpers/pycharm/tcunittest.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/helpers/pycharm/tcunittest.py b/python/helpers/pycharm/tcunittest.py index 055401764e38..6a93b219b5a3 100644 --- a/python/helpers/pycharm/tcunittest.py +++ b/python/helpers/pycharm/tcunittest.py @@ -69,8 +69,10 @@ class TeamcityTestResult(TestResult): error_value = err[1][0] if error_value.startswith("'") or error_value.startswith('"'): - first = self.find_first(err[1][0]) - second = self.find_second(err[1][0]) + # let's unescape strings to show sexy multiline diff in PyCharm. + # By default all caret return chars are escaped by testing framework + first = self._unescape(self.find_first(err[1][0])) + second = self._unescape(self.find_second(err[1][0])) else: first = second = "" err = self.formatErr(err) @@ -118,6 +120,9 @@ class TeamcityTestResult(TestResult): self.messages.testSuiteFinished(self.current_suite) self.current_suite = None + def _unescape(self, text): + return text.decode('string_escape') + class TeamcityTestRunner: def __init__(self, stream=sys.stdout): self.stream = stream