configtypes: Handle invalid format syntax.

This commit is contained in:
Florian Bruhin 2015-07-26 13:56:46 +02:00
parent 4bdf00b148
commit c750ff3f50
2 changed files with 3 additions and 0 deletions

View File

@ -1092,6 +1092,8 @@ class SearchEngineUrl(BaseType):
except (KeyError, IndexError) as e:
raise configexc.ValidationError(
value, "may not contain {...} (use {{ and }} for literal {/})")
except ValueError as e:
raise configexc.ValidationError(value, str(e))
url = QUrl(value.replace('{}', 'foobar'))
if not url.isValid():

View File

@ -1502,6 +1502,7 @@ class TestSearchEngineUrl:
':{}', # invalid URL
'foo{bar}baz{}', # {bar} format string variable
'{1}{}', # numbered format string variable
'{{}', # invalid format syntax
])
def test_validate_invalid(self, klass, val):
with pytest.raises(configexc.ValidationError):