summaryrefslogtreecommitdiff
path: root/testlib.py
diff options
context:
space:
mode:
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>2010-04-29 18:30:15 +0200
committerNicolas Chauvat <nicolas.chauvat@logilab.fr>2010-04-29 18:30:15 +0200
commitd4f2cc807a3acb9a5ca5e70d123bd834c8134484 (patch)
tree9468794f4a0dab5de5dafd0702538fc861786e51 /testlib.py
parent9205d8cf43ef7191dcbed9bb7cab4e85a1c4b8ba (diff)
downloadlogilab-common-d4f2cc807a3acb9a5ca5e70d123bd834c8134484.tar.gz
[testlib] add option splitlines to assertTextEquals
Diffstat (limited to 'testlib.py')
-rw-r--r--testlib.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/testlib.py b/testlib.py
index 410fa45..0d0946d 100644
--- a/testlib.py
+++ b/testlib.py
@@ -1491,7 +1491,7 @@ succeeded test into", osp.join(os.getcwd(),FILE_RESTART)
self.fail('\n'.join(['%s\n'%msg_prefix]+read + list(result)))
def assertTextEquals(self, text1, text2, junk=None,
- msg_prefix='Text differ'):
+ msg_prefix='Text differ', striplines=False):
"""compare two multiline strings (using difflib and splitlines())"""
msg = []
if not isinstance(text1, basestring):
@@ -1500,8 +1500,12 @@ succeeded test into", osp.join(os.getcwd(),FILE_RESTART)
msg.append('text2 is not a string (%s)'%(type(text2)))
if msg:
self.fail('\n'.join(msg))
- self._difftext(text1.strip().splitlines(True), text2.strip().splitlines(True),
- junk, msg_prefix)
+ lines1 = text1.strip().splitlines(True)
+ lines2 = text2.strip().splitlines(True)
+ if striplines:
+ lines1 = [line.strip() for line in lines1]
+ lines2 = [line.strip() for line in lines2]
+ self._difftext(lines1, lines2, junk, msg_prefix)
assertTextEqual = assertTextEquals
def assertStreamEquals(self, stream1, stream2, junk=None,