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

Side by Side Diff: tests/gcl_unittest.py

Issue 3473003: Add automated sys.stdout check. (Closed)
Patch Set: Created 10 years, 3 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 | « no previous file | tests/gclient_scm_test.py » ('j') | 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/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 gcl.py.""" 6 """Unit tests for gcl.py."""
7 7
8 # Fixes include path. 8 # Fixes include path.
9 from super_mox import mox, SuperMoxTestBase 9 from super_mox import mox, SuperMoxTestBase
10 10
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 gcl.sys.stdout.write("*** Upload does not submit a try; use gcl try to" 251 gcl.sys.stdout.write("*** Upload does not submit a try; use gcl try to"
252 " submit a try. ***") 252 " submit a try. ***")
253 gcl.sys.stdout.write("\n") 253 gcl.sys.stdout.write("\n")
254 change_info.Save() 254 change_info.Save()
255 gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) 255 gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir)
256 gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True 256 gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True
257 ).AndReturn(change_info) 257 ).AndReturn(change_info)
258 self.mox.ReplayAll() 258 self.mox.ReplayAll()
259 259
260 gcl.CMDupload(['naame', '-r', 'georges@example.com']) 260 gcl.CMDupload(['naame', '-r', 'georges@example.com'])
261 self.checkstdout('*** Upload does not submit a try; use gcl try to submit '
262 'a try. ***\n'
263 '*** Upload does not submit a try; use gcl try to submit a try. ***\n')
261 264
262 def testServerOverride(self): 265 def testServerOverride(self):
263 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', 266 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
264 [('A', 'aa'), ('M', 'bb')], 267 [('A', 'aa'), ('M', 'bb')],
265 self.fake_root_dir) 268 self.fake_root_dir)
266 self.mox.StubOutWithMock(change_info, 'Save') 269 self.mox.StubOutWithMock(change_info, 'Save')
267 change_info.Save() 270 change_info.Save()
268 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) 271 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
269 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') 272 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
270 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) 273 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
(...skipping 12 matching lines...) Expand all
283 gcl.os.chdir('somewhere') 286 gcl.os.chdir('somewhere')
284 gcl.sys.stdout.write("*** Upload does not submit a try; use gcl try to" 287 gcl.sys.stdout.write("*** Upload does not submit a try; use gcl try to"
285 " submit a try. ***") 288 " submit a try. ***")
286 gcl.sys.stdout.write("\n") 289 gcl.sys.stdout.write("\n")
287 gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) 290 gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir)
288 gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True 291 gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True
289 ).AndReturn(change_info) 292 ).AndReturn(change_info)
290 self.mox.ReplayAll() 293 self.mox.ReplayAll()
291 294
292 gcl.CMDupload(['naame', '--server=a', '--no_watchlists']) 295 gcl.CMDupload(['naame', '--server=a', '--no_watchlists'])
296 self.checkstdout('*** Upload does not submit a try; use gcl try to submit '
297 'a try. ***\n'
298 '*** Upload does not submit a try; use gcl try to submit a try. ***\n')
293 299
294 def testNormal(self): 300 def testNormal(self):
295 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription', 301 change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
296 [('A', 'aa'), ('M', 'bb')], 302 [('A', 'aa'), ('M', 'bb')],
297 self.fake_root_dir) 303 self.fake_root_dir)
298 self.mox.StubOutWithMock(change_info, 'Save') 304 self.mox.StubOutWithMock(change_info, 'Save')
299 change_info.Save() 305 change_info.Save()
300 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True) 306 gcl.DoPresubmitChecks(change_info, False, True).AndReturn(True)
301 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server') 307 gcl.GetCodeReviewSetting('CODE_REVIEW_SERVER').AndReturn('my_server')
302 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile')) 308 gcl.tempfile.mkstemp(text=True).AndReturn((42, 'descfile'))
(...skipping 14 matching lines...) Expand all
317 " submit a try. ***") 323 " submit a try. ***")
318 gcl.sys.stdout.write("\n") 324 gcl.sys.stdout.write("\n")
319 gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) 325 gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir)
320 gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True 326 gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True
321 ).AndReturn(change_info) 327 ).AndReturn(change_info)
322 self.mox.ReplayAll() 328 self.mox.ReplayAll()
323 329
324 gcl.CMDupload(['naame', '--no_watchlists']) 330 gcl.CMDupload(['naame', '--no_watchlists'])
325 self.assertEquals(change_info.issue, 1) 331 self.assertEquals(change_info.issue, 1)
326 self.assertEquals(change_info.patchset, 2) 332 self.assertEquals(change_info.patchset, 2)
333 self.checkstdout('*** Upload does not submit a try; use gcl try to submit '
334 'a try. ***\n'
335 '*** Upload does not submit a try; use gcl try to submit a try. ***\n')
327 336
328 def testNoServer(self): 337 def testNoServer(self):
329 self.mox.StubOutWithMock(gcl.sys, 'stderr') 338 self.mox.StubOutWithMock(gcl.sys, 'stderr')
330 gcl.sys.stderr.write( 339 gcl.sys.stderr.write(
331 'Don\'t use the -s flag, fix codereview.settings instead') 340 'Don\'t use the -s flag, fix codereview.settings instead')
332 gcl.sys.stderr.write('\n') 341 gcl.sys.stderr.write('\n')
333 gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir) 342 gcl.GetRepositoryRoot().AndReturn(self.fake_root_dir)
334 gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True 343 gcl.ChangeInfo.Load('naame', self.fake_root_dir, True, True
335 ).AndReturn(1) 344 ).AndReturn(1)
336 self.mox.ReplayAll() 345 self.mox.ReplayAll()
337 346
338 try: 347 try:
339 gcl.CMDupload(['naame', '-s', 'foo']) 348 gcl.CMDupload(['naame', '-s', 'foo'])
340 self.fail() 349 self.fail()
341 except SystemExit: 350 except SystemExit:
342 pass 351 pass
343 352
344 353
345 if __name__ == '__main__': 354 if __name__ == '__main__':
346 import unittest 355 import unittest
347 unittest.main() 356 unittest.main()
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698