OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Unit tests for subprocess2.py.""" | 6 """Unit tests for subprocess2.py.""" |
7 | 7 |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 results.update(kwargs) | 75 results.update(kwargs) |
76 results['args'] = args | 76 results['args'] = args |
77 def communicate(self): | 77 def communicate(self): |
78 return None, None | 78 return None, None |
79 subprocess2.subprocess.Popen = fake_Popen | 79 subprocess2.subprocess.Popen = fake_Popen |
80 return results | 80 return results |
81 | 81 |
82 def test_check_call_defaults(self): | 82 def test_check_call_defaults(self): |
83 results = self._fake_communicate() | 83 results = self._fake_communicate() |
84 self.assertEquals( | 84 self.assertEquals( |
85 ['stdout', 'stderr'], subprocess2.check_call(['foo'], a=True)) | 85 ['stdout', 'stderr'], subprocess2.check_call_out(['foo'], a=True)) |
86 expected = { | 86 expected = { |
87 'args': ['foo'], | 87 'args': ['foo'], |
88 'a':True, | 88 'a':True, |
89 } | 89 } |
90 self.assertEquals(expected, results) | 90 self.assertEquals(expected, results) |
91 | 91 |
92 def test_communicate_defaults(self): | 92 def test_communicate_defaults(self): |
93 results = self._fake_Popen() | 93 results = self._fake_Popen() |
94 self.assertEquals( | 94 self.assertEquals( |
95 ((None, None), -8), subprocess2.communicate(['foo'], a=True)) | 95 ((None, None), -8), subprocess2.communicate(['foo'], a=True)) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 do('CCC') | 199 do('CCC') |
200 if options.sleep: | 200 if options.sleep: |
201 time.sleep(10) | 201 time.sleep(10) |
202 return options.return_value | 202 return options.return_value |
203 | 203 |
204 | 204 |
205 if __name__ == '__main__': | 205 if __name__ == '__main__': |
206 if len(sys.argv) > 1 and sys.argv[1] == '--child': | 206 if len(sys.argv) > 1 and sys.argv[1] == '--child': |
207 sys.exit(child_main(sys.argv[2:])) | 207 sys.exit(child_main(sys.argv[2:])) |
208 unittest.main() | 208 unittest.main() |
OLD | NEW |