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

Unified Diff: tests/gclient_utils_test.py

Issue 3140023: Make codereview.setting syntax more liberal and add more unit tests. (Closed)
Patch Set: Created 10 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/gcl_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/gclient_utils_test.py
diff --git a/tests/gclient_utils_test.py b/tests/gclient_utils_test.py
index 01b22210714b9e689827c6d07b63ff891637b919..2779f8160f46a65c32a44377ce4fdde0964e6aed 100755
--- a/tests/gclient_utils_test.py
+++ b/tests/gclient_utils_test.py
@@ -78,30 +78,30 @@ class CheckCallTestCase(GclientUtilBase):
class SubprocessCallAndFilterTestCase(GclientUtilBase):
- def testSubprocessCallAndFilter(self):
- command = ['boo', 'foo', 'bar']
+ class ProcessIdMock(object):
+ def __init__(self, test_string):
+ self.stdout = StringIO.StringIO(test_string)
+ def wait(self):
+ pass
+
+ def _inner(self, command, test_string):
in_directory = 'bleh'
- fail_status = None
- pattern = 'a(.*)b'
- test_string = 'ahah\naccb\nallo\naddb\n'
env = gclient_utils.os.environ.copy()
env['LANGUAGE'] = 'en'
- class Mock(object):
- stdout = StringIO.StringIO(test_string)
- def wait(self):
- pass
- kid = Mock()
print("\n________ running 'boo foo bar' in 'bleh'")
for i in test_string:
gclient_utils.sys.stdout.write(i)
gclient_utils.subprocess.Popen(
- command, bufsize=0, cwd=in_directory,
+ command,
+ cwd=in_directory,
shell=(gclient_utils.sys.platform == 'win32'),
env=env,
stdout=gclient_utils.subprocess.PIPE,
- stderr=gclient_utils.subprocess.STDOUT).AndReturn(kid)
+ stderr=gclient_utils.subprocess.STDOUT,
+ bufsize=0).AndReturn(self.ProcessIdMock(test_string))
+
self.mox.ReplayAll()
- compiled_pattern = gclient_utils.re.compile(pattern)
+ compiled_pattern = gclient_utils.re.compile(r'a(.*)b')
line_list = []
capture_list = []
def FilterLines(line):
@@ -110,12 +110,21 @@ class SubprocessCallAndFilterTestCase(GclientUtilBase):
if match:
capture_list.append(match.group(1))
gclient_utils.SubprocessCallAndFilter(
- command, in_directory,
- True, True,
- fail_status, FilterLines)
+ command, in_directory, True, True, None, FilterLines)
self.assertEquals(line_list, ['ahah', 'accb', 'allo', 'addb'])
self.assertEquals(capture_list, ['cc', 'dd'])
+ def testSubprocessCallAndFilter(self):
+ command = ['boo', 'foo', 'bar']
+ test_string = 'ahah\naccb\nallo\naddb\n'
+ self._inner(command, test_string)
+
+ def testNoLF(self):
+ # Exactly as testSubprocessCallAndFilter without trailing \n
+ command = ['boo', 'foo', 'bar']
+ test_string = 'ahah\naccb\nallo\naddb'
+ self._inner(command, test_string)
+
class SplitUrlRevisionTestCase(GclientUtilBase):
def testSSHUrl(self):
« no previous file with comments | « tests/gcl_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698