Add tests for configtypes.Url
This commit is contained in:
parent
b4fec256dc
commit
b205ad500b
@ -1285,9 +1285,7 @@ class Url(BaseType):
|
||||
if not value:
|
||||
return
|
||||
val = self.transform(value)
|
||||
if val is None:
|
||||
raise configexc.ValidationError(value, "URL may not be empty!")
|
||||
elif not val.isValid():
|
||||
if not val.isValid():
|
||||
raise configexc.ValidationError(value, "invalid URL - "
|
||||
"{}".format(val.errorString()))
|
||||
|
||||
|
@ -1813,6 +1813,34 @@ class TestEncoding:
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
|
||||
class TestUrl:
|
||||
|
||||
"""Test Url."""
|
||||
|
||||
TESTS = {
|
||||
'http://qutebrowser.org/': QUrl('http://qutebrowser.org/'),
|
||||
'http://heise.de/': QUrl('http://heise.de/'),
|
||||
'': None,
|
||||
}
|
||||
|
||||
@pytest.fixture
|
||||
def klass(self):
|
||||
return configtypes.Url
|
||||
|
||||
@pytest.mark.parametrize('val', sorted(TESTS))
|
||||
def test_validate_valid(self, klass, val):
|
||||
klass(none_ok=True).validate(val)
|
||||
|
||||
@pytest.mark.parametrize('val', ['', '+'])
|
||||
def test_validate_invalid(self, klass, val):
|
||||
with pytest.raises(configexc.ValidationError):
|
||||
klass().validate(val)
|
||||
|
||||
@pytest.mark.parametrize('val, expected', sorted(TESTS.items()))
|
||||
def test_transform_single(self, klass, val, expected):
|
||||
assert klass().transform(val) == expected
|
||||
|
||||
|
||||
class TestSessionName:
|
||||
|
||||
"""Test SessionName."""
|
||||
|
Loading…
Reference in New Issue
Block a user