diff --git a/pytest_client_tools/insights_client.py b/pytest_client_tools/insights_client.py index 977204d..74f1fd8 100644 --- a/pytest_client_tools/insights_client.py +++ b/pytest_client_tools/insights_client.py @@ -112,6 +112,10 @@ def reload(self): with contextlib.suppress(configparser.DuplicateSectionError): self._config.add_section("insights-client") + def save(self): + with open(self._path, "w") as f: + self._config.write(f, space_around_delimiters=False) + def __getattr__(self, name): if name in self._KEYS_BOOL: read_func = self._config.getboolean diff --git a/tests/test_insights_client.py b/tests/test_insights_client.py index 1481631..1ee198d 100644 --- a/tests/test_insights_client.py +++ b/tests/test_insights_client.py @@ -83,6 +83,12 @@ def test_config_set_keys(tmp_path): # unknown key; setting will set a class attribute, not a config value conf.unknown = "see" assert conf.unknown == "see" + # save and check the result + conf.save() + conf_file_text = conf_file.read_text() + assert "cmd_timeout=60" in conf_file_text + assert "loglevel=DEBUG" in conf_file_text + assert "see" not in conf_file_text def test_config_reload(tmp_path):