config: Lists need to handle missing values
This commit is contained in:
parent
3c196ed645
commit
58976ef52d
@ -185,6 +185,8 @@ class List(ConfigValue):
|
||||
return tuple(values)
|
||||
|
||||
def serialize(self, value, display=False):
|
||||
if not value:
|
||||
return b''
|
||||
return b'\n ' + b'\n '.join(encode(v) for v in value if v)
|
||||
|
||||
|
||||
|
||||
@ -268,6 +268,12 @@ class ListTest(unittest.TestCase):
|
||||
self.assertIsInstance(result, bytes)
|
||||
self.assertRegexpMatches(result, r'foo\n\s*bar\n\s*baz')
|
||||
|
||||
def test_serialize_none(self):
|
||||
value = types.List()
|
||||
result = value.serialize(None)
|
||||
self.assertIsInstance(result, bytes)
|
||||
self.assertEqual(result, '')
|
||||
|
||||
|
||||
class LogLevelTest(unittest.TestCase):
|
||||
levels = {'critical': logging.CRITICAL,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user