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

Side by Side Diff: appengine/findit/util_scripts/test/script_util_test.py

Issue 2432203003: [Predator] Run predator. (Closed)
Patch Set: Rebase. Created 4 years, 1 month 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 | « appengine/findit/util_scripts/script_util.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import subprocess 5 import subprocess
6 6
7 from testing_utils import testing
8
7 import script_util 9 import script_util
8 from testing_utils import testing
9 10
10 11
11 class ScriptUtilTest(testing.AppengineTestCase): 12 class ScriptUtilTest(testing.AppengineTestCase):
12 13
13 # TODO(katesonia): Figure out a good way to work around cache. 14 # TODO(katesonia): Figure out a good way to work around cache.
14 def testGetLocalGitCommandOutput(self): 15 def testGetLocalGitCommandOutput(self):
15 class _MockProcess(object): 16 class _MockProcess(object):
16 def __init__(self, command, *_): 17 def __init__(self, command, *_):
17 self.command = command 18 self.command = command
18 19
19 def communicate(self, *_): 20 def communicate(self, *_):
20 return self.command, 'error' 21 return self.command, 'error'
21 22
22 @property 23 @property
23 def returncode(self): 24 def returncode(self):
24 return 1 if self.command == 'dummy' else 0 25 return 1 if self.command == 'dummy' else 0
25 26
26 self.mock(subprocess, 'Popen', lambda command, **_: _MockProcess(command)) 27 self.mock(subprocess, 'Popen', lambda command, **_: _MockProcess(command))
27 output = script_util.GetCommandOutput('command') 28 output = script_util.GetCommandOutput('command')
28 self.assertEqual(output, 'command') 29 self.assertEqual(output, 'command')
29 30
30 output = script_util.GetCommandOutput('dummy') 31 self.assertRaisesRegexp(Exception, 'Error running command dummy: error',
31 self.assertEqual(output, None) 32 script_util.GetCommandOutput, 'dummy')
OLDNEW
« no previous file with comments | « appengine/findit/util_scripts/script_util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698