Skip to content
Snippets Groups Projects
Commit e10e3efb authored by ulif's avatar ulif
Browse files

Interpolate ints in config files correctly.

parent 00ea69e9
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,10 @@ def get_config_dict(path_list=None):
return result
conf = dict(parser.items('diceware'))
for key, val in OPTIONS_DEFAULTS.items():
result[key] = conf.get(key, val)
new_val = conf.get(key, val)
if isinstance(val, int):
new_val = int(new_val)
result[key] = new_val
return result
......
......@@ -59,3 +59,11 @@ class TestConfigModule(object):
conf_dict = get_config_dict()
assert len(conf_dict) == len(OPTIONS_DEFAULTS)
assert conf_dict != OPTIONS_DEFAULTS
def test_get_config_dict_int(self, home_dir):
# integer values are interpolated correctly
config_file = home_dir / ".diceware.ini"
config_file.write("\n".join(["[diceware]", "num=3", ""]))
conf_dict = get_config_dict()
assert "num" in conf_dict.keys()
assert conf_dict["num"] == 3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment