OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for git_cl.py.""" | 6 """Unit tests for git_cl.py.""" |
7 | 7 |
8 import os | 8 import os |
9 import StringIO | 9 import StringIO |
10 import stat | 10 import stat |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 ] | 605 ] |
606 git_cl.main(['config']) | 606 git_cl.main(['config']) |
607 | 607 |
608 def test_update_reviewers(self): | 608 def test_update_reviewers(self): |
609 data = [ | 609 data = [ |
610 ('foo', [], 'foo'), | 610 ('foo', [], 'foo'), |
611 ('foo', ['a@c'], 'foo\n\nR=a@c'), | 611 ('foo', ['a@c'], 'foo\n\nR=a@c'), |
612 ('foo\nBUG=', ['a@c'], 'foo\nBUG=\nR=a@c'), | 612 ('foo\nBUG=', ['a@c'], 'foo\nBUG=\nR=a@c'), |
613 ('foo\nR=xx\nTBR=yy\nR=bar', ['a@c'], 'foo\nTBR=a@c'), | 613 ('foo\nR=xx\nTBR=yy\nR=bar', ['a@c'], 'foo\nTBR=a@c'), |
614 ('foo', ['a@c', 'b@c'], 'foo\n\nR=a@c, b@c'), | 614 ('foo', ['a@c', 'b@c'], 'foo\n\nR=a@c, b@c'), |
| 615 ('foo\nBar\n\nR=\nBUG=', ['c@c'], 'foo\nBar\n\nR=c@c\nBUG='), |
| 616 ('foo\nBar\n\nR=\nBUG=\nR=', ['c@c'], 'foo\nBar\n\nR=c@c\nBUG='), |
| 617 # Same as the line before, but full of whitespaces. |
| 618 ( |
| 619 'foo\nBar\n\n R = \n BUG = \n R = ', ['c@c'], |
| 620 'foo\nBar\n\nR=c@c\n BUG =', |
| 621 ), |
| 622 # Whitespaces aren't interpreted as new lines. |
| 623 ('foo BUG=allo R=joe ', ['c@c'], 'foo BUG=allo R=joe\n\nR=c@c'), |
615 ] | 624 ] |
616 for orig, reviewers, expected in data: | 625 expected = [i[2] for i in data] |
| 626 actual = [] |
| 627 for orig, reviewers, _expected in data: |
617 obj = git_cl.ChangeDescription(orig) | 628 obj = git_cl.ChangeDescription(orig) |
618 obj.update_reviewers(reviewers) | 629 obj.update_reviewers(reviewers) |
619 self.assertEqual(expected, obj.description) | 630 actual.append(obj.description) |
| 631 self.assertEqual(expected, actual) |
620 | 632 |
621 | 633 |
622 if __name__ == '__main__': | 634 if __name__ == '__main__': |
623 git_cl.logging.basicConfig( | 635 git_cl.logging.basicConfig( |
624 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 636 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
625 unittest.main() | 637 unittest.main() |
OLD | NEW |