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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 'a': True, | 118 'a': True, |
119 } | 119 } |
120 self.assertEquals(expected, results) | 120 self.assertEquals(expected, results) |
121 | 121 |
122 def test_Popen_defaults(self): | 122 def test_Popen_defaults(self): |
123 results = self._fake_subprocess_Popen() | 123 results = self._fake_subprocess_Popen() |
124 proc = subprocess2.Popen(['foo'], a=True) | 124 proc = subprocess2.Popen(['foo'], a=True) |
125 # Cleanup code in subprocess.py needs this member to be set. | 125 # Cleanup code in subprocess.py needs this member to be set. |
126 # pylint: disable=W0201 | 126 # pylint: disable=W0201 |
127 proc._child_created = None | 127 proc._child_created = None |
128 # Since subprocess.Popen.__init__() is not called, proc.returncode shouldn't | |
129 # be present. | |
130 self.assertFalse(hasattr(proc, 'returncode')) | |
131 expected = { | 128 expected = { |
132 'args': ['foo'], | 129 'args': ['foo'], |
133 'a': True, | 130 'a': True, |
134 'shell': bool(sys.platform=='win32'), | 131 'shell': bool(sys.platform=='win32'), |
135 } | 132 } |
136 if sys.platform != 'win32': | 133 if sys.platform != 'win32': |
137 env = os.environ.copy() | 134 env = os.environ.copy() |
138 is_english = lambda name: env.get(name, 'en').startswith('en') | 135 is_english = lambda name: env.get(name, 'en').startswith('en') |
139 if not is_english('LANG'): | 136 if not is_english('LANG'): |
140 env['LANG'] = 'en_US.UTF-8' | 137 env['LANG'] = 'en_US.UTF-8' |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 return options.return_value | 441 return options.return_value |
445 | 442 |
446 | 443 |
447 if __name__ == '__main__': | 444 if __name__ == '__main__': |
448 logging.basicConfig(level= | 445 logging.basicConfig(level= |
449 [logging.WARNING, logging.INFO, logging.DEBUG][ | 446 [logging.WARNING, logging.INFO, logging.DEBUG][ |
450 min(2, sys.argv.count('-v'))]) | 447 min(2, sys.argv.count('-v'))]) |
451 if len(sys.argv) > 1 and sys.argv[1] == '--child': | 448 if len(sys.argv) > 1 and sys.argv[1] == '--child': |
452 sys.exit(child_main(sys.argv[2:])) | 449 sys.exit(child_main(sys.argv[2:])) |
453 unittest.main() | 450 unittest.main() |
OLD | NEW |