# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1289507431 -3600 # Node ID 045120d3a110c34a0bd7b97a9ebf69f7244b6af3 # Parent 0d3139ba2d666421d2c5e3a07b0461d7ac4f817a test_utility_commands: use self.assertMultiLineEqual(). The previous assertStringEqual() utility method pointed to standard output. This is fairly annoying when running our own test-runner as it suppresses that output. The assertMultiLineEqual() method shows essentially the same information in the AssertionError itself. While at it, all other comparisons that contain line-breaks are made to use assertMultiLineEqual(). diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -271,17 +271,6 @@ class TestBase(unittest.TestCase): _verify_our_modules() - 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 ui(self, stupid=False, layout='auto'): return testui(stupid, layout) diff --git a/tests/test_utility_commands.py b/tests/test_utility_commands.py --- a/tests/test_utility_commands.py +++ b/tests/test_utility_commands.py @@ -42,7 +42,7 @@ class UtilityTests(test_util.TestBase): 'branch': 'branches/the_branch', 'rev': 5, }) - self.assertEqual(actual, expected) + self.assertMultiLineEqual(actual, expected) hg.update(self.repo, 'default') u.pushbuffer() svncommands.info(u, self.repo) @@ -53,7 +53,7 @@ class UtilityTests(test_util.TestBase): 'branch': 'trunk', 'rev': 6, }) - self.assertEqual(actual, expected) + self.assertMultiLineEqual(actual, expected) hg.update(self.repo, 'default') u.pushbuffer() svncommands.info(u, self.repo, rev=3) @@ -64,7 +64,7 @@ class UtilityTests(test_util.TestBase): 'branch': 'branches/the_branch', 'rev': 5, }) - self.assertEqual(actual, expected) + self.assertMultiLineEqual(actual, expected) def test_info_single(self): self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk') @@ -79,7 +79,7 @@ class UtilityTests(test_util.TestBase): 'branch': 'trunk', 'rev': 6, }) - self.assertStringEqual(expected, actual) + self.assertMultiLineEqual(expected, actual) def test_parent_output(self): self._load_fixture_and_fetch('two_heads.svndump') @@ -189,7 +189,7 @@ class UtilityTests(test_util.TestBase): u = self.ui() u.pushbuffer() svncommands.genignore(u, self.repo, self.wc_path) - self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), + self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') def test_genignore_single(self): @@ -198,7 +198,7 @@ class UtilityTests(test_util.TestBase): u = self.ui() u.pushbuffer() svncommands.genignore(u, self.repo, self.wc_path) - self.assertStringEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), + self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') def test_list_authors(self): @@ -210,7 +210,7 @@ class UtilityTests(test_util.TestBase): args=[test_util.fileurl(self.repo_path)], authors=None) actual = u.popbuffer() - self.assertEqual(actual, 'Augie\nevil\n') + self.assertMultiLineEqual(actual, 'Augie\nevil\n') def test_list_authors_map(self): @@ -220,7 +220,7 @@ class UtilityTests(test_util.TestBase): svncommands.listauthors(self.ui(), args=[test_util.fileurl(self.repo_path)], authors=author_path) - self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n') + self.assertMultiLineEqual(open(author_path).read(), 'Augie=\nevil=\n') def suite():