def _parse(self): parser = DotconfParser(self._config, debug=False, write_tables=False, errorlog=yacc.NullLogger()) return parser.parse()
def test_parser_basic(): test = ''' daemon = yes # This is a comment after an assignation # This is comment ''' parser = DotconfParser(test) output = parser.parse() assert output.get('daemon') is True
def test_parser_section(): test = ''' section1 { key = 'test' } section2 'arg' {} section3 'arg1', 'arg2' {} ''' parser = DotconfParser(test) output = parser.parse() assert tuple(output.subsections('section1'))[0].get('key') == 'test' assert tuple(output.subsections('section2'))[0].args == ['arg'] assert tuple(output.subsections('section3'))[0].args == ['arg1', 'arg2']
def test_parser_list(): test = ''' list1 = 1, 2, 3 list2 = 1, 2, 3, list3 = 1, list4 = 1, 2, 3 list5 = 1, 2, 3, ''' parser = DotconfParser(test) output = parser.parse() assert output.get('list1') == [1, 2, 3] assert output.get('list2') == [1, 2, 3] assert output.get('list3') == [1] assert output.get('list4') == [1, 2, 3] assert output.get('list5') == [1, 2, 3]
def test_parser_empty(): test = '''''' parser = DotconfParser(test) output = parser.parse()