diff options
author | Pierre-Yves David <pierre-yves.david@logilab.fr> | 2008-07-03 12:08:28 +0200 |
---|---|---|
committer | Pierre-Yves David <pierre-yves.david@logilab.fr> | 2008-07-03 12:08:28 +0200 |
commit | 30bb828dc7ba246f30b3bf0f62c25a5f5888abbf (patch) | |
tree | d3b4033d5746e135069dbb57cebada19f05a1d04 | |
parent | 15febb1bfc6c21731e4891bb0a6787f410501a46 (diff) | |
download | logilab-common-30bb828dc7ba246f30b3bf0f62c25a5f5888abbf.tar.gz |
add a prefix message option for assertTextEquals
-rw-r--r-- | testlib.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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 |