|
15 | 15 | # limitations under the License.
|
16 | 16 |
|
17 | 17 | import unittest
|
18 |
| -import os |
19 |
| -import re |
20 |
| -from builtins import super |
21 | 18 | from copy import copy
|
22 | 19 | from mbed_os_tools.test import init_host_test_cli_params
|
23 | 20 | from mbed_os_tools.test.host_tests_runner.host_test_default import DefaultTestSelector
|
24 |
| -from mock import patch, MagicMock |
25 | 21 |
|
26 | 22 | from .mocks.environment.linux import MockTestEnvironmentLinux
|
27 | 23 | from .mocks.environment.darwin import MockTestEnvironmentDarwin
|
|
30 | 26 | mock_platform_info = {
|
31 | 27 | "platform_name": "K64F",
|
32 | 28 | "target_id": "0240000031754e45000c0018948500156461000097969900",
|
33 |
| - "mount_point": os.path.normpath("mnt/DAPLINK"), |
34 |
| - "serial_port": os.path.normpath("dev/ttyACM0"), |
| 29 | + "mount_point": "/mnt/DAPLINK", |
| 30 | + "serial_port": "/dev/ttyACM0", |
35 | 31 | }
|
36 |
| -mock_image_path = os.path.normpath( |
37 |
| - "BUILD/tests/K64F/GCC_ARM/TESTS/network/interface/interface.bin" |
38 |
| -) |
| 32 | +mock_image_path = "BUILD/tests/K64F/GCC_ARM/TESTS/network/interface/interface.bin" |
39 | 33 |
|
40 | 34 | class BlackBoxHostTestTestCase(unittest.TestCase):
|
41 | 35 |
|
42 |
| - def test_host_test_linux(self): |
43 |
| - with MockTestEnvironmentLinux(self, mock_platform_info, mock_image_path) as _env: |
| 36 | + def _run_host_test(self, environment): |
| 37 | + with environment as _env: |
44 | 38 | test_selector = DefaultTestSelector(init_host_test_cli_params())
|
45 | 39 | result = test_selector.execute()
|
46 | 40 | test_selector.finish()
|
47 | 41 |
|
48 | 42 | self.assertEqual(result, 0)
|
49 | 43 |
|
50 |
| - def test_host_test_darwin(self): |
51 |
| - with MockTestEnvironmentDarwin(self, mock_platform_info, mock_image_path) as _env: |
52 |
| - test_selector = DefaultTestSelector(init_host_test_cli_params()) |
53 |
| - result = test_selector.execute() |
54 |
| - test_selector.finish() |
| 44 | + def test_host_test_linux(self): |
| 45 | + self._run_host_test( |
| 46 | + MockTestEnvironmentLinux(self, mock_platform_info, mock_image_path) |
| 47 | + ) |
55 | 48 |
|
56 |
| - self.assertEqual(result, 0) |
| 49 | + def test_host_test_darwin(self): |
| 50 | + self._run_host_test( |
| 51 | + MockTestEnvironmentDarwin(self, mock_platform_info, mock_image_path) |
| 52 | + ) |
57 | 53 |
|
58 | 54 | def test_host_test_windows(self):
|
59 | 55 | win_mock_platform_info = copy(mock_platform_info)
|
60 |
| - win_mock_platform_info["mount_point"] = "D:" |
61 | 56 | win_mock_platform_info["serial_port"] = "COM5"
|
62 |
| - with MockTestEnvironmentWindows(self, mock_platform_info, mock_image_path) as _env: |
63 |
| - test_selector = DefaultTestSelector(init_host_test_cli_params()) |
64 |
| - result = test_selector.execute() |
65 |
| - test_selector.finish() |
66 | 57 |
|
67 |
| - self.assertEqual(result, 0) |
| 58 | + self._run_host_test( |
| 59 | + MockTestEnvironmentWindows(self, win_mock_platform_info, mock_image_path) |
| 60 | + ) |
68 | 61 |
|
69 | 62 | if __name__ == '__main__':
|
70 | 63 | unittest.main()
|
0 commit comments