From 41655e78524849c15991a47fa15aa0bbf63fe9bf Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 15 Jun 2017 18:04:48 +0200 Subject: [PATCH] Fix handling of none_ok in List/Dict We now always return None (and '' as string) when the user configured an empty list or dict. --- qutebrowser/config/configdata.yml | 3 +++ tests/unit/config/test_configtypes.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 900eab571..90f401db3 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -21,6 +21,7 @@ yank_ignored_url_parameters: type: name: List valtype: String + none_ok: true default: - ref - utm_source @@ -1232,6 +1233,7 @@ hints.hide_unmatched_rapid_hints: searchengines: default: + # FIXME:conf what if the user deletes/renames DEFAULT? DEFAULT: https://duckduckgo.com/?q={} type: name: Dict @@ -1249,6 +1251,7 @@ aliases: name: String forbidden: ' ' valtype: Command + none_ok: true desc: Command aliases FIXME # colors diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py index f74f6c34a..6afd8bd12 100644 --- a/tests/unit/config/test_configtypes.py +++ b/tests/unit/config/test_configtypes.py @@ -573,7 +573,8 @@ class TestList: except configexc.ValidationError: pass else: - assert typ.to_str(converted) == text + expected = '' if not val else text + assert typ.to_str(converted) == expected class TestFlagList: @@ -1407,7 +1408,8 @@ class TestDict: except configexc.ValidationError: pass else: - assert d.to_str(converted) == text + expected = '' if not val else text + assert d.to_str(converted) == expected def unrequired_class(**kwargs):