Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Side by Side Diff: tests/git_footers_test.py

Issue 1915833003: tryserver recipe_module: Add get_tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Minor things. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/gclient_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 """Tests for git_footers.""" 3 """Tests for git_footers."""
4 4
5 import os 5 import os
6 import StringIO
6 import sys 7 import sys
7 import unittest 8 import unittest
8 9
9 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10 11
12 from testing_support.auto_stub import TestCase
13
11 import git_footers 14 import git_footers
12 15
13 class GitFootersTest(unittest.TestCase): 16 class GitFootersTest(TestCase):
14 _message = """ 17 _message = """
15 This is my commit message. There are many like it, but this one is mine. 18 This is my commit message. There are many like it, but this one is mine.
16 19
17 My commit message is my best friend. It is my life. I must master it. 20 My commit message is my best friend. It is my life. I must master it.
18 21
19 """ 22 """
20 23
21 _position = 'refs/heads/master@{#292272}' 24 _position = 'refs/heads/master@{#292272}'
22 25
23 _position_footer = 'Cr-Commit-Position: %s\n' % _position 26 _position_footer = 'Cr-Commit-Position: %s\n' % _position
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 100
98 self.assertEqual( 101 self.assertEqual(
99 git_footers.add_footer_change_id('header\n\nBUG: yy\n\nPos: 1', 'Ixxx'), 102 git_footers.add_footer_change_id('header\n\nBUG: yy\n\nPos: 1', 'Ixxx'),
100 'header\n\nBUG: yy\n\nChange-Id: Ixxx\nPos: 1') 103 'header\n\nBUG: yy\n\nChange-Id: Ixxx\nPos: 1')
101 104
102 # Special case: first line is never a footer, even if it looks line one. 105 # Special case: first line is never a footer, even if it looks line one.
103 self.assertEqual( 106 self.assertEqual(
104 git_footers.add_footer_change_id('header: like footer', 'Ixxx'), 107 git_footers.add_footer_change_id('header: like footer', 'Ixxx'),
105 'header: like footer\n\nChange-Id: Ixxx') 108 'header: like footer\n\nChange-Id: Ixxx')
106 109
110 def testReadStdin(self):
111 self.mock(git_footers.sys, 'stdin', StringIO.StringIO(
112 'line\r\notherline\r\n\r\n\r\nFoo: baz'))
113
114 stdout = StringIO.StringIO()
115 self.mock(git_footers.sys, 'stdout', stdout)
116
117 self.assertEqual(git_footers.main([]), 0)
118 self.assertEqual(stdout.getvalue(), "Foo: baz\n")
119
120
107 121
108 if __name__ == '__main__': 122 if __name__ == '__main__':
109 unittest.main() 123 unittest.main()
OLDNEW
« no previous file with comments | « tests/gclient_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698