def test_setup_tool_cfg(self, os_mock, Tools_mock, ConfiguredTool_mock, log_mock): # Prepares mocks def info(text): pass # print text # for debug only def existing_file(f): return True log_mock.info = info log_mock.error = info log_mock.warning = info prelude.XmakeException = info prelude.is_existing_file = existing_file buildConfig = BuildConfig() buildConfig.cfg_dir = MagicMock(return_value=os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'samples')) buildConfig.component_dir = MagicMock(return_value=os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', 'samples')) tools = Tools_mock() tools.is_declared_tool = lambda tid: False if tid != 'msvc' else True buildConfig._tools = tools # Runs test prelude.setup_tool_cfg(buildConfig) # Asserts assert (ConfiguredTool_mock.call_count > 0)
def stubBuildConfig(cfg_dir, component_dir): # template to create buildConfig in test cases cfg = BuildConfig() cfg._runtime = "linux" cfg._tools = Tools() cfg._tools.import_tools_dir=cfg.import_tools_dir cfg._tools.runtime=cfg.runtime cfg.cfg_dir = MagicMock(return_value=cfg_dir) cfg.component_dir = MagicMock(return_value=component_dir) return cfg