configtypes: Fix ' ' value with Command.
This commit is contained in:
parent
ebdfa0be73
commit
44bf4ae883
@ -546,7 +546,8 @@ class Command(BaseType):
|
|||||||
self._basic_validation(value)
|
self._basic_validation(value)
|
||||||
if not value:
|
if not value:
|
||||||
return
|
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!")
|
raise configexc.ValidationError(value, "must be a valid command!")
|
||||||
|
|
||||||
def complete(self):
|
def complete(self):
|
||||||
|
@ -706,7 +706,7 @@ class TestCommand:
|
|||||||
def test_validate_valid(self, klass, val):
|
def test_validate_valid(self, klass, val):
|
||||||
klass(none_ok=True).validate(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):
|
def test_validate_invalid(self, klass, val):
|
||||||
with pytest.raises(configexc.ValidationError):
|
with pytest.raises(configexc.ValidationError):
|
||||||
klass().validate(val)
|
klass().validate(val)
|
||||||
|
Loading…
Reference in New Issue
Block a user