| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Unittests for test_dispatcher.py.""" | 6 """Unittests for test_dispatcher.py.""" |
| 7 # pylint: disable=R0201 | 7 # pylint: disable=R0201 |
| 8 # pylint: disable=W0212 | 8 # pylint: disable=W0212 |
| 9 | 9 |
| 10 import os | 10 import os |
| 11 import sys | 11 import sys |
| 12 import unittest | 12 import unittest |
| 13 | 13 |
| 14 | 14 |
| 15 from devil.android import device_utils | 15 from devil.android import device_utils |
| 16 from devil.android.sdk import adb_wrapper | 16 from devil.android.sdk import adb_wrapper |
| 17 from devil.utils import watchdog_timer | 17 from devil.utils import watchdog_timer |
| 18 from pylib import constants | 18 from pylib import constants |
| 19 from pylib.base import base_test_result | 19 from pylib.base import base_test_result |
| 20 from pylib.base import test_collection | 20 from pylib.base import test_collection |
| 21 from pylib.base import test_dispatcher | 21 from pylib.base import test_dispatcher |
| 22 | 22 |
| 23 sys.path.append( | 23 sys.path.append( |
| 24 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) | 24 os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) |
| 25 import mock | 25 import mock # pylint: disable=import-error |
| 26 | 26 |
| 27 | 27 |
| 28 class TestException(Exception): | 28 class TestException(Exception): |
| 29 pass | 29 pass |
| 30 | 30 |
| 31 | 31 |
| 32 def _MockDevice(serial): | 32 def _MockDevice(serial): |
| 33 d = mock.MagicMock(spec=device_utils.DeviceUtils) | 33 d = mock.MagicMock(spec=device_utils.DeviceUtils) |
| 34 d.__str__.return_value = serial | 34 d.__str__.return_value = serial |
| 35 d.adb = mock.MagicMock(spec=adb_wrapper.AdbWrapper) | 35 d.adb = mock.MagicMock(spec=adb_wrapper.AdbWrapper) |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 232 |
| 233 def testNoTests(self): | 233 def testNoTests(self): |
| 234 results, exit_code = test_dispatcher.RunTests( | 234 results, exit_code = test_dispatcher.RunTests( |
| 235 [], MockRunner, [_MockDevice('0'), _MockDevice('1')], shard=False) | 235 [], MockRunner, [_MockDevice('0'), _MockDevice('1')], shard=False) |
| 236 self.assertEqual(len(results.GetAll()), 0) | 236 self.assertEqual(len(results.GetAll()), 0) |
| 237 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE) | 237 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE) |
| 238 | 238 |
| 239 | 239 |
| 240 if __name__ == '__main__': | 240 if __name__ == '__main__': |
| 241 unittest.main() | 241 unittest.main() |
| OLD | NEW |