def _validate( setting, value, option_parser, config_parser=None, config_section=None ): string_list = frontend.validate_comma_separated_list( setting, value, option_parser, config_parser, config_section ) if len(string_list) != length: raise ValueError( f"Expecting {length} items in {setting}, got {len(string_list)}." ) return tuple(string_list)
def test_validate_comma_separated_list(self): tests = ( (u'a', ['a',] ), ('a', ['a',] ), (u'a,b', ['a', 'b'] ), ('a,b', ['a', 'b'] ), ([u'a',], ['a',] ), ([u'a', u'b,c'], ['a', 'b', 'c'] ), (['a', 'b,c'], ['a', 'b', 'c'] ), ) for t in tests: self.assertEqual( frontend.validate_comma_separated_list(None, t[0], None), t[1])