| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 self.fail() | 161 self.fail() |
| 162 except TypeError: | 162 except TypeError: |
| 163 pass | 163 pass |
| 164 | 164 |
| 165 def test_stdout_void(self): | 165 def test_stdout_void(self): |
| 166 (out, err), code = subprocess2.communicate( | 166 (out, err), code = subprocess2.communicate( |
| 167 self.exe + ['--stdout', '--stderr'], | 167 self.exe + ['--stdout', '--stderr'], |
| 168 stdout=subprocess2.VOID, | 168 stdout=subprocess2.VOID, |
| 169 stderr=subprocess2.PIPE) | 169 stderr=subprocess2.PIPE) |
| 170 self.assertEquals(None, out) | 170 self.assertEquals(None, out) |
| 171 self.assertEquals('a\nbb\nccc\n', err) | 171 expected = 'a\nbb\nccc\n' |
| 172 if sys.platform == 'win32': |
| 173 expected = expected.replace('\n', '\r\n') |
| 174 self.assertEquals(expected, err) |
| 172 self.assertEquals(0, code) | 175 self.assertEquals(0, code) |
| 173 | 176 |
| 174 def test_stderr_void(self): | 177 def test_stderr_void(self): |
| 175 (out, err), code = subprocess2.communicate( | 178 (out, err), code = subprocess2.communicate( |
| 176 self.exe + ['--stdout', '--stderr'], | 179 self.exe + ['--stdout', '--stderr'], |
| 177 universal_newlines=True, | 180 universal_newlines=True, |
| 178 stdout=subprocess2.PIPE, | 181 stdout=subprocess2.PIPE, |
| 179 stderr=subprocess2.VOID) | 182 stderr=subprocess2.VOID) |
| 180 self.assertEquals('A\nBB\nCCC\n', out) | 183 self.assertEquals('A\nBB\nCCC\n', out) |
| 181 self.assertEquals(None, err) | 184 self.assertEquals(None, err) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 do('CCC') | 262 do('CCC') |
| 260 if options.sleep: | 263 if options.sleep: |
| 261 time.sleep(10) | 264 time.sleep(10) |
| 262 return options.return_value | 265 return options.return_value |
| 263 | 266 |
| 264 | 267 |
| 265 if __name__ == '__main__': | 268 if __name__ == '__main__': |
| 266 if len(sys.argv) > 1 and sys.argv[1] == '--child': | 269 if len(sys.argv) > 1 and sys.argv[1] == '--child': |
| 267 sys.exit(child_main(sys.argv[2:])) | 270 sys.exit(child_main(sys.argv[2:])) |
| 268 unittest.main() | 271 unittest.main() |
| OLD | NEW |