summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Yves David <pierre-yves.david@logilab.fr>2008-07-03 12:08:28 +0200
committerPierre-Yves David <pierre-yves.david@logilab.fr>2008-07-03 12:08:28 +0200
commit30bb828dc7ba246f30b3bf0f62c25a5f5888abbf (patch)
treed3b4033d5746e135069dbb57cebada19f05a1d04
parent15febb1bfc6c21731e4891bb0a6787f410501a46 (diff)
downloadlogilab-common-30bb828dc7ba246f30b3bf0f62c25a5f5888abbf.tar.gz
add a prefix message option for assertTextEquals
-rw-r--r--testlib.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/testlib.py b/testlib.py
index b91a297..a341ef1 100644
--- a/testlib.py
+++ b/testlib.py
@@ -1301,7 +1301,8 @@ class TestCase(unittest.TestCase):
if not line.startswith(' '):
self.fail(''.join(['%s\n'%msg_prefix]+read + list(result)))
- def assertTextEquals(self, text1, text2, junk=None):
+ def assertTextEquals(self, text1, text2, junk=None,
+ msg_prefix='Text differ'):
"""compare two multiline strings (using difflib and splitlines())"""
msg = []
if not isinstance(text1, basestring):
@@ -1310,11 +1311,12 @@ class TestCase(unittest.TestCase):
msg.append('text2 is not a string (%s)'%(type(text2)))
if msg:
self.fail('\n'.join(msg))
- self._difftext(text1.splitlines(True), text2.splitlines(True), junk)
+ self._difftext(text1.splitlines(True), text2.splitlines(True), junk,
+ msg_prefix)
assertTextEqual = assertTextEquals
def assertStreamEquals(self, stream1, stream2, junk=None,
- msg_prefix='Stream differ'):
+ msg_prefix='Stream differ'):
"""compare two streams (using difflib and readlines())"""
# if stream2 is stream2, readlines() on stream1 will also read lines
# in stream2, so they'll appear different, although they're not