Mercurial > hgsubversion
comparison tests/test_util.py @ 548:2148eb4b4da4
test_util: add assertStringEqual to output diff output for string checks
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 06 Feb 2010 10:57:06 -0600 |
parents | d84116dda52d |
children | d96aa92d9ad9 |
comparison
equal
deleted
inserted
replaced
547:9e6499c415a9 | 548:2148eb4b4da4 |
---|---|
1 import StringIO | 1 import StringIO |
2 import difflib | |
2 import errno | 3 import errno |
3 import gettext | 4 import gettext |
4 import imp | 5 import imp |
5 import os | 6 import os |
6 import shutil | 7 import shutil |
177 os.environ[var] = val | 178 os.environ[var] = val |
178 i18n.t = self.oldt | 179 i18n.t = self.oldt |
179 rmtree(self.tmpdir) | 180 rmtree(self.tmpdir) |
180 os.chdir(self.oldwd) | 181 os.chdir(self.oldwd) |
181 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) | 182 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) |
183 | |
184 def assertStringEqual(self, l, r): | |
185 try: | |
186 self.assertEqual(l, r, 'failed string equality check, see stdout for details') | |
187 except: | |
188 add_nl = lambda li: map(lambda x: x+'\n', li) | |
189 print 'failed expectation:' | |
190 print ''.join(difflib.unified_diff( | |
191 add_nl(l.splitlines()), add_nl(r.splitlines()), | |
192 fromfile='expected', tofile='got')) | |
193 raise | |
182 | 194 |
183 def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, layout='auto'): | 195 def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, layout='auto'): |
184 if layout == 'single': | 196 if layout == 'single': |
185 if subdir is None: | 197 if subdir is None: |
186 subdir = 'trunk' | 198 subdir = 'trunk' |