configtypes: Fix ' ' value with Command.

This commit is contained in:
Florian Bruhin 2015-07-24 17:56:12 +02:00
parent ebdfa0be73
commit 44bf4ae883
2 changed files with 3 additions and 2 deletions

View File

@ -546,7 +546,8 @@ class Command(BaseType):
self._basic_validation(value)
if not value:
return
elif value.split()[0] not in cmdutils.cmd_dict:
splitted = value.split()
if not splitted or splitted[0] not in cmdutils.cmd_dict:
raise configexc.ValidationError(value, "must be a valid command!")
def complete(self):

View File

@ -706,7 +706,7 @@ class TestCommand:
def test_validate_valid(self, klass, val):
klass(none_ok=True).validate(val)
@pytest.mark.parametrize('val', ['', 'cmd3', 'cmd3 foo bar'])
@pytest.mark.parametrize('val', ['', 'cmd3', 'cmd3 foo bar', ' '])
def test_validate_invalid(self, klass, val):
with pytest.raises(configexc.ValidationError):
klass().validate(val)