| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 trychange.py.""" | 6 """Unit tests for trychange.py.""" |
| 7 | 7 |
| 8 # pylint: disable=E1103,W0403 | 8 # pylint: disable=E1103,W0403 |
| 9 | 9 |
| 10 # Fixes include path. | 10 # Fixes include path. |
| 11 from super_mox import SuperMoxTestBase | 11 from super_mox import SuperMoxTestBase |
| 12 | 12 |
| 13 import subprocess2 |
| 13 import trychange | 14 import trychange |
| 14 | 15 |
| 15 | 16 |
| 16 class TryChangeTestsBase(SuperMoxTestBase): | 17 class TryChangeTestsBase(SuperMoxTestBase): |
| 17 """Setups and tear downs the mocks but doesn't test anything as-is.""" | 18 """Setups and tear downs the mocks but doesn't test anything as-is.""" |
| 18 def setUp(self): | 19 def setUp(self): |
| 19 SuperMoxTestBase.setUp(self) | 20 SuperMoxTestBase.setUp(self) |
| 20 self.mox.StubOutWithMock(trychange.gclient_utils, 'CheckCall') | 21 self.mox.StubOutWithMock(subprocess2, 'communicate') |
| 21 self.mox.StubOutWithMock(trychange.scm.GIT, 'Capture') | 22 self.mox.StubOutWithMock(trychange.scm.GIT, 'Capture') |
| 22 self.mox.StubOutWithMock(trychange.scm.GIT, 'GenerateDiff') | 23 self.mox.StubOutWithMock(trychange.scm.GIT, 'GenerateDiff') |
| 23 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetCheckoutRoot') | 24 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetCheckoutRoot') |
| 24 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetEmail') | 25 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetEmail') |
| 25 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetPatchName') | 26 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetPatchName') |
| 26 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetUpstreamBranch') | 27 self.mox.StubOutWithMock(trychange.scm.GIT, 'GetUpstreamBranch') |
| 27 self.mox.StubOutWithMock(trychange.scm.SVN, 'DiffItem') | 28 self.mox.StubOutWithMock(trychange.scm.SVN, 'DiffItem') |
| 28 self.mox.StubOutWithMock(trychange.scm.SVN, 'GenerateDiff') | 29 self.mox.StubOutWithMock(trychange.scm.SVN, 'GenerateDiff') |
| 29 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetCheckoutRoot') | 30 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetCheckoutRoot') |
| 30 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetEmail') | 31 self.mox.StubOutWithMock(trychange.scm.SVN, 'GetEmail') |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 self.mox.ReplayAll() | 101 self.mox.ReplayAll() |
| 101 git = trychange.GIT(self.options, self.fake_root) | 102 git = trychange.GIT(self.options, self.fake_root) |
| 102 self.assertEqual(git.GetFileNames(), self.expected_files) | 103 self.assertEqual(git.GetFileNames(), self.expected_files) |
| 103 self.assertEqual(git.checkout_root, self.fake_root) | 104 self.assertEqual(git.checkout_root, self.fake_root) |
| 104 self.assertEqual(git.GenerateDiff(), 'A diff') | 105 self.assertEqual(git.GenerateDiff(), 'A diff') |
| 105 | 106 |
| 106 | 107 |
| 107 if __name__ == '__main__': | 108 if __name__ == '__main__': |
| 108 import unittest | 109 import unittest |
| 109 unittest.main() | 110 unittest.main() |
| OLD | NEW |