Rev 4970: Remove duplicated code. in file:///home/vila/src/bzr/bugs/476293-log-check-ancestor/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Jan 21 18:15:08 GMT 2010
At file:///home/vila/src/bzr/bugs/476293-log-check-ancestor/
------------------------------------------------------------
revno: 4970
revision-id: v.ladeuil+lp at free.fr-20100121181508-wqciwy39018jinph
parent: v.ladeuil+lp at free.fr-20100121173845-8wa4wlusyowu5r75
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: respect-direction
timestamp: Thu 2010-01-21 19:15:08 +0100
message:
Remove duplicated code.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_log.py'
--- a/bzrlib/tests/test_log.py 2010-01-21 17:38:45 +0000
+++ b/bzrlib/tests/test_log.py 2010-01-21 18:15:08 +0000
@@ -1347,41 +1347,42 @@
class TestLogFormatter(tests.TestCase):
+ def setUp(self):
+ super(TestLogFormatter, self).setUp()
+ self.rev = revision.Revision('a-id')
+ self.lf = log.LogFormatter(None)
+
def test_short_committer(self):
- rev = revision.Revision('a-id')
- rev.committer = 'John Doe <jdoe at example.com>'
- lf = log.LogFormatter(None)
- self.assertEqual('John Doe', lf.short_committer(rev))
- rev.committer = 'John Smith <jsmith at example.com>'
- self.assertEqual('John Smith', lf.short_committer(rev))
- rev.committer = 'John Smith'
- self.assertEqual('John Smith', lf.short_committer(rev))
- rev.committer = 'jsmith at example.com'
- self.assertEqual('jsmith at example.com', lf.short_committer(rev))
- rev.committer = '<jsmith at example.com>'
- self.assertEqual('jsmith at example.com', lf.short_committer(rev))
- rev.committer = 'John Smith jsmith at example.com'
- self.assertEqual('John Smith', lf.short_committer(rev))
+ def assertCommitter(expected, committer):
+ self.rev.committer = committer
+ self.assertEqual(expected, self.lf.short_committer(self.rev))
+
+ assertCommitter('John Doe', 'John Doe <jdoe at example.com>')
+ assertCommitter('John Smith', 'John Smith <jsmith at example.com>')
+ assertCommitter('John Smith', 'John Smith')
+ assertCommitter('jsmith at example.com', 'jsmith at example.com')
+ assertCommitter('jsmith at example.com', '<jsmith at example.com>')
+ assertCommitter('John Smith', 'John Smith jsmith at example.com')
def test_short_author(self):
- rev = revision.Revision('a-id')
- rev.committer = 'John Doe <jdoe at example.com>'
- lf = log.LogFormatter(None)
- self.assertEqual('John Doe', lf.short_author(rev))
- rev.properties['author'] = 'John Smith <jsmith at example.com>'
- self.assertEqual('John Smith', lf.short_author(rev))
- rev.properties['author'] = 'John Smith'
- self.assertEqual('John Smith', lf.short_author(rev))
- rev.properties['author'] = 'jsmith at example.com'
- self.assertEqual('jsmith at example.com', lf.short_author(rev))
- rev.properties['author'] = '<jsmith at example.com>'
- self.assertEqual('jsmith at example.com', lf.short_author(rev))
- rev.properties['author'] = 'John Smith jsmith at example.com'
- self.assertEqual('John Smith', lf.short_author(rev))
- del rev.properties['author']
- rev.properties['authors'] = ('John Smith <jsmith at example.com>\n'
- 'Jane Rey <jrey at example.com>')
- self.assertEqual('John Smith', lf.short_author(rev))
+ def assertAuthor(expected, author):
+ self.rev.properties['author'] = author
+ self.assertEqual(expected, self.lf.short_author(self.rev))
+
+ assertAuthor('John Smith', 'John Smith <jsmith at example.com>')
+ assertAuthor('John Smith', 'John Smith')
+ assertAuthor('jsmith at example.com', 'jsmith at example.com')
+ assertAuthor('jsmith at example.com', '<jsmith at example.com>')
+ assertAuthor('John Smith', 'John Smith jsmith at example.com')
+
+ def test_short_author_from_committer(self):
+ self.rev.committer = 'John Doe <jdoe at example.com>'
+ self.assertEqual('John Doe', self.lf.short_author(self.rev))
+
+ def test_short_author_from_authors(self):
+ self.rev.properties['authors'] = ('John Smith <jsmith at example.com>\n'
+ 'Jane Rey <jrey at example.com>')
+ self.assertEqual('John Smith', self.lf.short_author(self.rev))
class TestReverseByDepth(tests.TestCase):
More information about the bazaar-commits
mailing list