Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
|
chanli
2016/11/08 01:56:20
Nit: 2016
Sharu Jiang
2016/11/11 00:29:06
Done.
| |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import subprocess | |
| 6 | |
| 7 import script_util | |
| 8 from testing_utils import testing | |
| 9 | |
| 10 | |
| 11 class ScriptUtilTest(testing.AppengineTestCase): | |
| 12 | |
| 13 def testGetLocalGitCommandOutput(self): | |
| 14 class _MockProcess(object): | |
| 15 def __init__(self, command, *_): | |
| 16 self.command = command | |
| 17 | |
| 18 def communicate(self, *_): | |
| 19 return self.command, 'dummy' | |
| 20 | |
| 21 @property | |
| 22 def returncode(self): | |
| 23 return 1 if self.command == 'dummy' else 0 | |
| 24 | |
| 25 self.mock(subprocess, 'Popen', lambda command, **_: _MockProcess(command)) | |
| 26 output = script_util.GetCommandOutput('command') | |
| 27 self.assertEqual(output, 'command') | |
| 28 | |
| 29 output = script_util.GetCommandOutput('dummy') | |
| 30 self.assertEqual(output, None) | |
| OLD | NEW |