OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 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 # pylint: disable=protected-access | 6 # pylint: disable=protected-access |
7 | 7 |
8 import unittest | 8 import unittest |
9 | 9 |
10 from pylib.base import base_test_result | 10 from pylib.base import base_test_result |
11 from pylib.constants import host_paths | 11 from pylib.constants import host_paths |
12 from pylib.local.device import local_device_test_run | 12 from pylib.local.device import local_device_test_run |
13 | 13 |
14 with host_paths.SysPath(host_paths.PYMOCK_PATH): | 14 with host_paths.SysPath(host_paths.PYMOCK_PATH): |
15 import mock # pylint: disable=import-error | 15 import mock # pylint: disable=import-error |
16 | 16 |
17 | 17 |
| 18 class SubstituteDeviceRootTest(unittest.TestCase): |
| 19 |
| 20 def testNoneDevicePath(self): |
| 21 self.assertEquals( |
| 22 '/fake/device/root', |
| 23 local_device_test_run.SubstituteDeviceRoot( |
| 24 None, '/fake/device/root')) |
| 25 |
| 26 def testStringDevicePath(self): |
| 27 self.assertEquals( |
| 28 '/another/fake/device/path', |
| 29 local_device_test_run.SubstituteDeviceRoot( |
| 30 '/another/fake/device/path', '/fake/device/root')) |
| 31 |
| 32 def testListWithNoneDevicePath(self): |
| 33 self.assertEquals( |
| 34 '/fake/device/root/subpath', |
| 35 local_device_test_run.SubstituteDeviceRoot( |
| 36 [None, 'subpath'], '/fake/device/root')) |
| 37 |
| 38 def testListWithoutNoneDevicePath(self): |
| 39 self.assertEquals( |
| 40 '/another/fake/device/path', |
| 41 local_device_test_run.SubstituteDeviceRoot( |
| 42 ['/', 'another', 'fake', 'device', 'path'], |
| 43 '/fake/device/root')) |
| 44 |
| 45 |
18 class TestLocalDeviceTestRun(local_device_test_run.LocalDeviceTestRun): | 46 class TestLocalDeviceTestRun(local_device_test_run.LocalDeviceTestRun): |
19 | 47 |
20 # pylint: disable=abstract-method | 48 # pylint: disable=abstract-method |
21 | 49 |
22 def __init__(self): | 50 def __init__(self): |
23 super(TestLocalDeviceTestRun, self).__init__( | 51 super(TestLocalDeviceTestRun, self).__init__( |
24 mock.MagicMock(), mock.MagicMock()) | 52 mock.MagicMock(), mock.MagicMock()) |
25 | 53 |
26 | 54 |
27 class TestLocalDeviceNonStringTestRun( | 55 class TestLocalDeviceNonStringTestRun( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 165 |
138 test_run = TestLocalDeviceNonStringTestRun() | 166 test_run = TestLocalDeviceNonStringTestRun() |
139 tests_to_retry = test_run._GetTestsToRetry(tests, try_results) | 167 tests_to_retry = test_run._GetTestsToRetry(tests, try_results) |
140 self.assertEquals(1, len(tests_to_retry)) | 168 self.assertEquals(1, len(tests_to_retry)) |
141 self.assertIsInstance(tests_to_retry[0], dict) | 169 self.assertIsInstance(tests_to_retry[0], dict) |
142 self.assertEquals(tests[1], tests_to_retry[0]) | 170 self.assertEquals(tests[1], tests_to_retry[0]) |
143 | 171 |
144 | 172 |
145 if __name__ == '__main__': | 173 if __name__ == '__main__': |
146 unittest.main(verbosity=2) | 174 unittest.main(verbosity=2) |
OLD | NEW |