| 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 1435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 def test_description_set_stdin(self): | 1446 def test_description_set_stdin(self): |
| 1447 out = StringIO.StringIO() | 1447 out = StringIO.StringIO() |
| 1448 self.mock(git_cl.sys, 'stdout', out) | 1448 self.mock(git_cl.sys, 'stdout', out) |
| 1449 | 1449 |
| 1450 self.mock(git_cl, 'Changelist', ChangelistMock) | 1450 self.mock(git_cl, 'Changelist', ChangelistMock) |
| 1451 self.mock(git_cl.sys, 'stdin', StringIO.StringIO('hi \r\n\t there\n\nman')) | 1451 self.mock(git_cl.sys, 'stdin', StringIO.StringIO('hi \r\n\t there\n\nman')) |
| 1452 | 1452 |
| 1453 self.assertEqual(0, git_cl.main(['description', '-n', '-'])) | 1453 self.assertEqual(0, git_cl.main(['description', '-n', '-'])) |
| 1454 self.assertEqual('hi\n\t there\n\nman', ChangelistMock.desc) | 1454 self.assertEqual('hi\n\t there\n\nman', ChangelistMock.desc) |
| 1455 | 1455 |
| 1456 def test_cmd_issue_erase_existing(self): |
| 1457 out = StringIO.StringIO() |
| 1458 self.mock(git_cl.sys, 'stdout', out) |
| 1459 self.calls = [ |
| 1460 ((['git', 'symbolic-ref', 'HEAD'],), 'feature'), |
| 1461 ((['git', 'config', 'branch.feature.rietveldissue'],), ''), |
| 1462 ((['git', 'config', 'branch.feature.gerritissue'],), '123'), |
| 1463 ((['git', 'config', '--unset', 'branch.feature.gerritissue'],), ''), |
| 1464 ((['git', 'config', '--unset', 'branch.feature.gerritpatchset'],), ''), |
| 1465 # Let this command raise exception (retcode=1) - it should be ignored. |
| 1466 ((['git', 'config', '--unset', 'branch.feature.last-upload-hash'],), |
| 1467 '', subprocess2.CalledProcessError(1, '', '', '', '')), |
| 1468 ((['git', 'config', '--unset', 'branch.feature.gerritserver'],), ''), |
| 1469 ((['git', 'config', '--unset', 'branch.feature.gerritsquashhash'],), |
| 1470 ''), |
| 1471 ] |
| 1472 self.assertEqual(0, git_cl.main(['issue', '0'])) |
| 1473 |
| 1456 | 1474 |
| 1457 if __name__ == '__main__': | 1475 if __name__ == '__main__': |
| 1458 git_cl.logging.basicConfig( | 1476 git_cl.logging.basicConfig( |
| 1459 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) | 1477 level=git_cl.logging.DEBUG if '-v' in sys.argv else git_cl.logging.ERROR) |
| 1460 unittest.main() | 1478 unittest.main() |
| OLD | NEW |