Test and fix configtypes to_str.
This commit is contained in:
parent
4c2f65819b
commit
ecba175b16
@ -171,7 +171,7 @@ class BaseType:
|
|||||||
Arguments:
|
Arguments:
|
||||||
value: The value to check.
|
value: The value to check.
|
||||||
"""
|
"""
|
||||||
assert isinstance(value, str)
|
assert isinstance(value, str), value
|
||||||
if not value and not self.none_ok:
|
if not value and not self.none_ok:
|
||||||
raise configexc.ValidationError(value, "may not be empty!")
|
raise configexc.ValidationError(value, "may not be empty!")
|
||||||
if any(ord(c) < 32 or ord(c) == 0x7f for c in value):
|
if any(ord(c) < 32 or ord(c) == 0x7f for c in value):
|
||||||
@ -233,7 +233,7 @@ class BaseType:
|
|||||||
"""
|
"""
|
||||||
if value is None:
|
if value is None:
|
||||||
return ''
|
return ''
|
||||||
assert isinstance(value, str)
|
assert isinstance(value, str), value
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def complete(self):
|
def complete(self):
|
||||||
@ -1141,6 +1141,11 @@ class ShellCommand(BaseType):
|
|||||||
"{}-placeholder.")
|
"{}-placeholder.")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def to_str(self, value):
|
||||||
|
if not value:
|
||||||
|
return ''
|
||||||
|
return json.dumps(value)
|
||||||
|
|
||||||
|
|
||||||
class Proxy(BaseType):
|
class Proxy(BaseType):
|
||||||
|
|
||||||
|
@ -33,7 +33,9 @@ def test_init():
|
|||||||
assert isinstance(configdata.DATA, dict)
|
assert isinstance(configdata.DATA, dict)
|
||||||
assert 'ignore_case' in configdata.DATA
|
assert 'ignore_case' in configdata.DATA
|
||||||
for option in configdata.DATA.values():
|
for option in configdata.DATA.values():
|
||||||
|
# Make sure to_py and to_str work
|
||||||
option.typ.to_py(option.default)
|
option.typ.to_py(option.default)
|
||||||
|
option.typ.to_str(option.default)
|
||||||
|
|
||||||
|
|
||||||
def test_init_benchmark(benchmark):
|
def test_init_benchmark(benchmark):
|
||||||
|
Loading…
Reference in New Issue
Block a user