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 | |
46 class TestLocalDeviceTestRun(local_device_test_run.LocalDeviceTestRun): | 18 class TestLocalDeviceTestRun(local_device_test_run.LocalDeviceTestRun): |
47 | 19 |
48 # pylint: disable=abstract-method | 20 # pylint: disable=abstract-method |
49 | 21 |
50 def __init__(self): | 22 def __init__(self): |
51 super(TestLocalDeviceTestRun, self).__init__( | 23 super(TestLocalDeviceTestRun, self).__init__( |
52 mock.MagicMock(), mock.MagicMock()) | 24 mock.MagicMock(), mock.MagicMock()) |
53 | 25 |
54 | 26 |
55 class TestLocalDeviceNonStringTestRun( | 27 class TestLocalDeviceNonStringTestRun( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 137 |
166 test_run = TestLocalDeviceNonStringTestRun() | 138 test_run = TestLocalDeviceNonStringTestRun() |
167 tests_to_retry = test_run._GetTestsToRetry(tests, try_results) | 139 tests_to_retry = test_run._GetTestsToRetry(tests, try_results) |
168 self.assertEquals(1, len(tests_to_retry)) | 140 self.assertEquals(1, len(tests_to_retry)) |
169 self.assertIsInstance(tests_to_retry[0], dict) | 141 self.assertIsInstance(tests_to_retry[0], dict) |
170 self.assertEquals(tests[1], tests_to_retry[0]) | 142 self.assertEquals(tests[1], tests_to_retry[0]) |
171 | 143 |
172 | 144 |
173 if __name__ == '__main__': | 145 if __name__ == '__main__': |
174 unittest.main(verbosity=2) | 146 unittest.main(verbosity=2) |
OLD | NEW |