OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 """Mocks the whole subprocess2.Popen class.""" | 71 """Mocks the whole subprocess2.Popen class.""" |
72 results = {} | 72 results = {} |
73 class fake_Popen(object): | 73 class fake_Popen(object): |
74 returncode = -8 | 74 returncode = -8 |
75 def __init__(self, args, **kwargs): | 75 def __init__(self, args, **kwargs): |
76 assert not results | 76 assert not results |
77 results.update(kwargs) | 77 results.update(kwargs) |
78 results['args'] = args | 78 results['args'] = args |
79 @staticmethod | 79 @staticmethod |
80 # pylint: disable=W0622 | 80 # pylint: disable=W0622 |
81 def communicate(input=None, timeout=None, nag_timer=None): | 81 def communicate(input=None, timeout=None, nag_max=None, nag_timer=None): |
82 return None, None | 82 return None, None |
83 self.mock(subprocess2, 'Popen', fake_Popen) | 83 self.mock(subprocess2, 'Popen', fake_Popen) |
84 return results | 84 return results |
85 | 85 |
86 def _fake_subprocess_Popen(self): | 86 def _fake_subprocess_Popen(self): |
87 """Mocks the base class subprocess.Popen only.""" | 87 """Mocks the base class subprocess.Popen only.""" |
88 results = {} | 88 results = {} |
89 def __init__(self, args, **kwargs): | 89 def __init__(self, args, **kwargs): |
90 assert not results | 90 assert not results |
91 results.update(kwargs) | 91 results.update(kwargs) |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 return options.return_value | 671 return options.return_value |
672 | 672 |
673 | 673 |
674 if __name__ == '__main__': | 674 if __name__ == '__main__': |
675 logging.basicConfig(level= | 675 logging.basicConfig(level= |
676 [logging.WARNING, logging.INFO, logging.DEBUG][ | 676 [logging.WARNING, logging.INFO, logging.DEBUG][ |
677 min(2, sys.argv.count('-v'))]) | 677 min(2, sys.argv.count('-v'))]) |
678 if len(sys.argv) > 1 and sys.argv[1] == '--child': | 678 if len(sys.argv) > 1 and sys.argv[1] == '--child': |
679 sys.exit(child_main(sys.argv[2:])) | 679 sys.exit(child_main(sys.argv[2:])) |
680 unittest.main() | 680 unittest.main() |
OLD | NEW |