diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-10-15 16:07:49 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:54 +0100 |
commit | 35bc2e98583d3e04e9310ea3950549f64da7fb6d (patch) | |
tree | 5c7c7e80c6e1a6fa4f9e308216ad00f9532369a5 | |
parent | 094868a40f22aa09b412ef8db4ea2eb885433e0c (diff) | |
download | wee-slack-35bc2e98583d3e04e9310ea3950549f64da7fb6d.tar.gz |
Fix bug with setting bool config values
-rw-r--r-- | slack/weechat_config.py | 7 | ||||
-rw-r--r-- | tests/conftest.py | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/slack/weechat_config.py b/slack/weechat_config.py index 6e6cb85..9c0c098 100644 --- a/slack/weechat_config.py +++ b/slack/weechat_config.py @@ -102,9 +102,12 @@ class WeeChatOption(Generic[WeeChatOptionType]): @value.setter def value(self, value: WeeChatOptionType): - rc = self.value_set_as_str(str(value)) + value_str = ( + str(value).lower() if isinstance(self.default_value, bool) else str(value) + ) + rc = self.value_set_as_str(value_str) if rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR: - raise Exception(f"Failed to value for option: {self.name}") + raise Exception(f"Failed to set value for option: {self.name}") def value_set_as_str(self, value: str) -> int: return weechat.config_option_set(self._pointer, value, 1) diff --git a/tests/conftest.py b/tests/conftest.py index d1cf16a..0b3cada 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -88,7 +88,7 @@ def config_option_set(option: str, value: str, run_callback: int) -> int: def config_boolean(option: str) -> int: - return config_values.get(option) == "True" + return config_values.get(option) in ["true", "on", "yes", "y", "true", "t", "1"] def config_integer(option: str) -> int: |