Chromium Code Reviews| Index: appengine/findit/util_scripts/test/script_util_test.py |
| diff --git a/appengine/findit/util_scripts/test/script_util_test.py b/appengine/findit/util_scripts/test/script_util_test.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e32c31595013f54a7998ceab29f2199295de88d4 |
| --- /dev/null |
| +++ b/appengine/findit/util_scripts/test/script_util_test.py |
| @@ -0,0 +1,30 @@ |
| +# 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.
|
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import subprocess |
| + |
| +import script_util |
| +from testing_utils import testing |
| + |
| + |
| +class ScriptUtilTest(testing.AppengineTestCase): |
| + |
| + def testGetLocalGitCommandOutput(self): |
| + class _MockProcess(object): |
| + def __init__(self, command, *_): |
| + self.command = command |
| + |
| + def communicate(self, *_): |
| + return self.command, 'dummy' |
| + |
| + @property |
| + def returncode(self): |
| + return 1 if self.command == 'dummy' else 0 |
| + |
| + self.mock(subprocess, 'Popen', lambda command, **_: _MockProcess(command)) |
| + output = script_util.GetCommandOutput('command') |
| + self.assertEqual(output, 'command') |
| + |
| + output = script_util.GetCommandOutput('dummy') |
| + self.assertEqual(output, None) |