Mercurial > hgsubversion
comparison tests/test_utility_commands.py @ 743:045120d3a110
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().
| author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
|---|---|
| date | Thu, 11 Nov 2010 21:30:31 +0100 |
| parents | d2ef7220a079 |
| children | 174f03c288d4 |
comparison
equal
deleted
inserted
replaced
| 742:0d3139ba2d66 | 743:045120d3a110 |
|---|---|
| 40 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', | 40 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', |
| 41 'repourl': self.repourl, | 41 'repourl': self.repourl, |
| 42 'branch': 'branches/the_branch', | 42 'branch': 'branches/the_branch', |
| 43 'rev': 5, | 43 'rev': 5, |
| 44 }) | 44 }) |
| 45 self.assertEqual(actual, expected) | 45 self.assertMultiLineEqual(actual, expected) |
| 46 hg.update(self.repo, 'default') | 46 hg.update(self.repo, 'default') |
| 47 u.pushbuffer() | 47 u.pushbuffer() |
| 48 svncommands.info(u, self.repo) | 48 svncommands.info(u, self.repo) |
| 49 actual = u.popbuffer() | 49 actual = u.popbuffer() |
| 50 expected = (expected_info_output % | 50 expected = (expected_info_output % |
| 51 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', | 51 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', |
| 52 'repourl': self.repourl, | 52 'repourl': self.repourl, |
| 53 'branch': 'trunk', | 53 'branch': 'trunk', |
| 54 'rev': 6, | 54 'rev': 6, |
| 55 }) | 55 }) |
| 56 self.assertEqual(actual, expected) | 56 self.assertMultiLineEqual(actual, expected) |
| 57 hg.update(self.repo, 'default') | 57 hg.update(self.repo, 'default') |
| 58 u.pushbuffer() | 58 u.pushbuffer() |
| 59 svncommands.info(u, self.repo, rev=3) | 59 svncommands.info(u, self.repo, rev=3) |
| 60 actual = u.popbuffer() | 60 actual = u.popbuffer() |
| 61 expected = (expected_info_output % | 61 expected = (expected_info_output % |
| 62 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', | 62 {'date': '2008-10-08 01:39:05 +0000 (Wed, 08 Oct 2008)', |
| 63 'repourl': self.repourl, | 63 'repourl': self.repourl, |
| 64 'branch': 'branches/the_branch', | 64 'branch': 'branches/the_branch', |
| 65 'rev': 5, | 65 'rev': 5, |
| 66 }) | 66 }) |
| 67 self.assertEqual(actual, expected) | 67 self.assertMultiLineEqual(actual, expected) |
| 68 | 68 |
| 69 def test_info_single(self): | 69 def test_info_single(self): |
| 70 self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk') | 70 self._load_fixture_and_fetch('two_heads.svndump', subdir='trunk') |
| 71 hg.update(self.repo, 'tip') | 71 hg.update(self.repo, 'tip') |
| 72 u = self.ui() | 72 u = self.ui() |
| 77 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', | 77 {'date': '2008-10-08 01:39:29 +0000 (Wed, 08 Oct 2008)', |
| 78 'repourl': self.repourl, | 78 'repourl': self.repourl, |
| 79 'branch': 'trunk', | 79 'branch': 'trunk', |
| 80 'rev': 6, | 80 'rev': 6, |
| 81 }) | 81 }) |
| 82 self.assertStringEqual(expected, actual) | 82 self.assertMultiLineEqual(expected, actual) |
| 83 | 83 |
| 84 def test_parent_output(self): | 84 def test_parent_output(self): |
| 85 self._load_fixture_and_fetch('two_heads.svndump') | 85 self._load_fixture_and_fetch('two_heads.svndump') |
| 86 u = self.ui() | 86 u = self.ui() |
| 87 u.pushbuffer() | 87 u.pushbuffer() |
| 187 test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path, | 187 test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path, |
| 188 self.wc_path, noupdate=False) | 188 self.wc_path, noupdate=False) |
| 189 u = self.ui() | 189 u = self.ui() |
| 190 u.pushbuffer() | 190 u.pushbuffer() |
| 191 svncommands.genignore(u, self.repo, self.wc_path) | 191 svncommands.genignore(u, self.repo, self.wc_path) |
| 192 self.assertEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), | 192 self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), |
| 193 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') | 193 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') |
| 194 | 194 |
| 195 def test_genignore_single(self): | 195 def test_genignore_single(self): |
| 196 self._load_fixture_and_fetch('ignores.svndump', subdir='trunk') | 196 self._load_fixture_and_fetch('ignores.svndump', subdir='trunk') |
| 197 hg.update(self.repo, 'tip') | 197 hg.update(self.repo, 'tip') |
| 198 u = self.ui() | 198 u = self.ui() |
| 199 u.pushbuffer() | 199 u.pushbuffer() |
| 200 svncommands.genignore(u, self.repo, self.wc_path) | 200 svncommands.genignore(u, self.repo, self.wc_path) |
| 201 self.assertStringEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), | 201 self.assertMultiLineEqual(open(os.path.join(self.wc_path, '.hgignore')).read(), |
| 202 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') | 202 '.hgignore\nsyntax:glob\nblah\notherblah\nbaz/magic\n') |
| 203 | 203 |
| 204 def test_list_authors(self): | 204 def test_list_authors(self): |
| 205 test_util.load_svndump_fixture(self.repo_path, | 205 test_util.load_svndump_fixture(self.repo_path, |
| 206 'replace_trunk_with_branch.svndump') | 206 'replace_trunk_with_branch.svndump') |
| 208 u.pushbuffer() | 208 u.pushbuffer() |
| 209 svncommands.listauthors(u, | 209 svncommands.listauthors(u, |
| 210 args=[test_util.fileurl(self.repo_path)], | 210 args=[test_util.fileurl(self.repo_path)], |
| 211 authors=None) | 211 authors=None) |
| 212 actual = u.popbuffer() | 212 actual = u.popbuffer() |
| 213 self.assertEqual(actual, 'Augie\nevil\n') | 213 self.assertMultiLineEqual(actual, 'Augie\nevil\n') |
| 214 | 214 |
| 215 | 215 |
| 216 def test_list_authors_map(self): | 216 def test_list_authors_map(self): |
| 217 test_util.load_svndump_fixture(self.repo_path, | 217 test_util.load_svndump_fixture(self.repo_path, |
| 218 'replace_trunk_with_branch.svndump') | 218 'replace_trunk_with_branch.svndump') |
| 219 author_path = os.path.join(self.repo_path, 'authors') | 219 author_path = os.path.join(self.repo_path, 'authors') |
| 220 svncommands.listauthors(self.ui(), | 220 svncommands.listauthors(self.ui(), |
| 221 args=[test_util.fileurl(self.repo_path)], | 221 args=[test_util.fileurl(self.repo_path)], |
| 222 authors=author_path) | 222 authors=author_path) |
| 223 self.assertEqual(open(author_path).read(), 'Augie=\nevil=\n') | 223 self.assertMultiLineEqual(open(author_path).read(), 'Augie=\nevil=\n') |
| 224 | 224 |
| 225 | 225 |
| 226 def suite(): | 226 def suite(): |
| 227 all = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), | 227 all = [unittest.TestLoader().loadTestsFromTestCase(UtilityTests), |
| 228 ] | 228 ] |
