def test_global_tools_overrided(self): client = TestClient() conanfile = """ from conans import ConanFile, tools class HelloConan(ConanFile): name = "Hello" version = "0.1" def build(self): assert(tools._global_requester != None) assert(tools._global_output != None) """ client.save({"conanfile.py": conanfile}) client.run("install .") client.run("build .") # Not test the real commmand get_command if it's setting the module global vars tmp = temp_folder() conf = get_default_client_conf().replace( "\n[proxies]", "\n[proxies]\nhttp = http://myproxy.com") os.mkdir(os.path.join(tmp, ".conan")) save(os.path.join(tmp, ".conan", CONAN_CONF), conf) with tools.environment_append({"CONAN_USER_HOME": tmp}): conan_api, _, _ = ConanAPIV1.factory() conan_api.remote_list() global_output, global_requester = get_global_instances() self.assertEqual(global_requester.proxies, {"http": "http://myproxy.com"}) self.assertIsNotNone(global_output.warn)
def config(self): if not self._config: if not os.path.exists(self.conan_conf_path): save(self.conan_conf_path, normalize(get_default_client_conf())) self._config = ConanClientConfigParser(self.conan_conf_path) return self._config
def test_cache_config(self): file_path = os.path.join(temp_folder(), "whatever_cacert") save(file_path, "") conan_conf = os.path.join(temp_folder(), "conan.conf") save(conan_conf, normalize(get_default_client_conf())) replace_in_file(conan_conf, "# cacert_path", "cacert_path={}".format(file_path), output=TestBufferConanOutput()) config = ConanClientConfigParser(conan_conf) mocked_requester = MockRequesterGet() requester = ConanRequester(config, mocked_requester) requester.get(url="bbbb", verify=True) self.assertEqual(mocked_requester.verify, file_path)
def initialize_config(self): if not os.path.exists(self.conan_conf_path): save(self.conan_conf_path, normalize(get_default_client_conf()))