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

Unified Diff: tests/subprocess2_test.py

Issue 6877005: Make subprocess2.call() returned values to be the same as subprocess.call(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 8 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 | « subprocess2.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/subprocess2_test.py
diff --git a/tests/subprocess2_test.py b/tests/subprocess2_test.py
index 552a93c49eea7585c07122c328b1e3cd18181174..c419df022da9585f1fe3e17a2ae709928c303b68 100755
--- a/tests/subprocess2_test.py
+++ b/tests/subprocess2_test.py
@@ -22,8 +22,9 @@ import subprocess2
class Subprocess2Test(unittest.TestCase):
# Can be mocked in a test.
TO_SAVE = {
- subprocess2: ['Popen', 'call', 'check_call', 'capture', 'check_output'],
- subprocess2.subprocess: ['Popen'],
+ subprocess2: [
+ 'Popen', 'communicate', 'call', 'check_call', 'capture', 'check_output'],
+ subprocess2.subprocess: ['Popen'],
}
def setUp(self):
@@ -40,14 +41,14 @@ class Subprocess2Test(unittest.TestCase):
setattr(module, name, value)
@staticmethod
- def _fake_call():
+ def _fake_communicate():
results = {}
- def fake_call(args, **kwargs):
+ def fake_communicate(args, **kwargs):
assert not results
results.update(kwargs)
results['args'] = args
return ['stdout', 'stderr'], 0
- subprocess2.call = fake_call
+ subprocess2.communicate = fake_communicate
return results
@staticmethod
@@ -79,7 +80,7 @@ class Subprocess2Test(unittest.TestCase):
return results
def test_check_call_defaults(self):
- results = self._fake_call()
+ results = self._fake_communicate()
self.assertEquals(
['stdout', 'stderr'], subprocess2.check_call(['foo'], a=True))
expected = {
@@ -88,9 +89,10 @@ class Subprocess2Test(unittest.TestCase):
}
self.assertEquals(expected, results)
- def test_call_defaults(self):
+ def test_communicate_defaults(self):
results = self._fake_Popen()
- self.assertEquals(((None, None), -8), subprocess2.call(['foo'], a=True))
+ self.assertEquals(
+ ((None, None), -8), subprocess2.communicate(['foo'], a=True))
expected = {
'args': ['foo'],
'a': True,
@@ -118,9 +120,9 @@ class Subprocess2Test(unittest.TestCase):
self.assertEquals(expected, results)
def test_check_output_defaults(self):
- results = self._fake_call()
+ results = self._fake_communicate()
# It's discarding 'stderr' because it assumes stderr=subprocess2.STDOUT but
- # fake_call() doesn't 'implement' that.
+ # fake_communicate() doesn't 'implement' that.
self.assertEquals('stdout', subprocess2.check_output(['foo'], a=True))
expected = {
'args': ['foo'],
@@ -133,7 +135,7 @@ class Subprocess2Test(unittest.TestCase):
def test_timeout(self):
# It'd be better to not discard stdout.
- out, returncode = subprocess2.call(
+ out, returncode = subprocess2.communicate(
self.exe + ['--sleep', '--stdout'],
timeout=0.01,
stdout=subprocess2.PIPE)
« no previous file with comments | « subprocess2.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698