diff --git a/jug/options.py b/jug/options.py index c142e2c..8b4611b 100644 --- a/jug/options.py +++ b/jug/options.py @@ -149,7 +149,10 @@ def read_configuration_file(fp=None, default_options=None): old_value = getattr(default_options, new_name, None) if old_value is not None: # Cast the config object to the same type as the default - value = type(old_value)(value) + if isinstance(old_value, bool): + value = _str_to_bool(value) + else: + value = type(old_value)(value) logging.debug("Setting %s to %s", new_name, value) setattr(inifile, new_name, value) diff --git a/jug/tests/test_options.py b/jug/tests/test_options.py index 673376d..ce51493 100644 --- a/jug/tests/test_options.py +++ b/jug/tests/test_options.py @@ -83,3 +83,17 @@ def test_bool(): assert _str_to_bool("on") assert _str_to_bool("true") assert _str_to_bool("1") + + +_bool_options_file = """ +[main] +will-cite=false +""" + + +def test_bool_from_config(): + opts = jug.options.read_configuration_file( + StringIO(_bool_options_file), + default_options=jug.options.default_options, + ) + assert opts.will_cite is False