| 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 logging | 8 import logging |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 def test_stdin_unicode(self): | 393 def test_stdin_unicode(self): |
| 394 def fn(c, e, un): | 394 def fn(c, e, un): |
| 395 stdin = u'0123456789' | 395 stdin = u'0123456789' |
| 396 res = subprocess2.communicate( | 396 res = subprocess2.communicate( |
| 397 e + ['--read'], | 397 e + ['--read'], |
| 398 stdin=stdin, | 398 stdin=stdin, |
| 399 universal_newlines=un) | 399 universal_newlines=un) |
| 400 self._check_res(res, None, None, 10) | 400 self._check_res(res, None, None, 10) |
| 401 self._run_test(fn) | 401 self._run_test(fn) |
| 402 | 402 |
| 403 def test_stdin_empty(self): |
| 404 def fn(c, e, un): |
| 405 stdin = '' |
| 406 res = subprocess2.communicate( |
| 407 e + ['--read'], |
| 408 stdin=stdin, |
| 409 universal_newlines=un) |
| 410 self._check_res(res, None, None, 0) |
| 411 self._run_test(fn) |
| 412 |
| 403 def test_stdin_void(self): | 413 def test_stdin_void(self): |
| 404 res = subprocess2.communicate(self.exe + ['--read'], stdin=VOID) | 414 res = subprocess2.communicate(self.exe + ['--read'], stdin=VOID) |
| 405 self._check_res(res, None, None, 0) | 415 self._check_res(res, None, None, 0) |
| 406 | 416 |
| 407 def test_stdin_void_stdout_timeout(self): | 417 def test_stdin_void_stdout_timeout(self): |
| 408 # Make sure a mix of VOID, PIPE and timeout works. | 418 # Make sure a mix of VOID, PIPE and timeout works. |
| 409 def fn(c, e, un): | 419 def fn(c, e, un): |
| 410 res = subprocess2.communicate( | 420 res = subprocess2.communicate( |
| 411 e + ['--stdout', '--read'], | 421 e + ['--stdout', '--read'], |
| 412 stdin=VOID, | 422 stdin=VOID, |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 return options.return_value | 642 return options.return_value |
| 633 | 643 |
| 634 | 644 |
| 635 if __name__ == '__main__': | 645 if __name__ == '__main__': |
| 636 logging.basicConfig(level= | 646 logging.basicConfig(level= |
| 637 [logging.WARNING, logging.INFO, logging.DEBUG][ | 647 [logging.WARNING, logging.INFO, logging.DEBUG][ |
| 638 min(2, sys.argv.count('-v'))]) | 648 min(2, sys.argv.count('-v'))]) |
| 639 if len(sys.argv) > 1 and sys.argv[1] == '--child': | 649 if len(sys.argv) > 1 and sys.argv[1] == '--child': |
| 640 sys.exit(child_main(sys.argv[2:])) | 650 sys.exit(child_main(sys.argv[2:])) |
| 641 unittest.main() | 651 unittest.main() |
| OLD | NEW |