20
20
from mock import patch , MagicMock
21
21
from tools .build_api import prepare_toolchain , build_project , build_library ,\
22
22
scan_resources
23
+ from tools .toolchains import TOOLCHAINS
23
24
24
25
"""
25
26
Tests for build_api.py
26
27
"""
28
+ make_mock_target = namedtuple (
29
+ "Target" , "init_hooks name features core supported_toolchains" )
27
30
28
31
class BuildApiTests (unittest .TestCase ):
29
32
"""
@@ -82,9 +85,8 @@ def test_prepare_toolchain_app_config(self, mock_config_init):
82
85
:return:
83
86
"""
84
87
app_config = "app_config"
85
- mock_target = namedtuple ("Target" ,
86
- "init_hooks name features core" )(lambda _ , __ : None ,
87
- "Junk" , [], "Cortex-M3" )
88
+ mock_target = make_mock_target (lambda _ , __ : None ,
89
+ "Junk" , [], "Cortex-M3" , TOOLCHAINS )
88
90
mock_config_init .return_value = namedtuple (
89
91
"Config" , "target has_regions name" )(mock_target , False , None )
90
92
@@ -102,9 +104,8 @@ def test_prepare_toolchain_no_app_config(self, mock_config_init):
102
104
:param mock_config_init: mock of Config __init__
103
105
:return:
104
106
"""
105
- mock_target = namedtuple ("Target" ,
106
- "init_hooks name features core" )(lambda _ , __ : None ,
107
- "Junk" , [], "Cortex-M3" )
107
+ mock_target = make_mock_target (lambda _ , __ : None ,
108
+ "Junk" , [], "Cortex-M3" , TOOLCHAINS )
108
109
mock_config_init .return_value = namedtuple (
109
110
"Config" , "target has_regions name" )(mock_target , False , None )
110
111
0 commit comments