# HG changeset patch # User Augie Fackler # Date 1265475426 21600 # Node ID 2148eb4b4da4c18f0cb1616b4c465df860f9a5d0 # Parent 9e6499c415a91efbf4d81bfe59ccf1ba0fe87059 test_util: add assertStringEqual to output diff output for string checks diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,4 +1,5 @@ import StringIO +import difflib import errno import gettext import imp @@ -180,6 +181,17 @@ class TestBase(unittest.TestCase): os.chdir(self.oldwd) setattr(ui.ui, self.patch[0].func_name, self.patch[0]) + def assertStringEqual(self, l, r): + try: + self.assertEqual(l, r, 'failed string equality check, see stdout for details') + except: + add_nl = lambda li: map(lambda x: x+'\n', li) + print 'failed expectation:' + print ''.join(difflib.unified_diff( + add_nl(l.splitlines()), add_nl(r.splitlines()), + fromfile='expected', tofile='got')) + raise + def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, layout='auto'): if layout == 'single': if subdir is None: