def test_raises_when_unexpected_lines_appear(self): invalid_line_list = [ "first invalid line", "second = 'invalid line' something else #comment", "third = 'invalid line 'something#'#", ] line_list = ["site = 1.1.1.1"] + invalid_line_list with self.assertRaises(config_parser.InvalidLines) as context_manager: # testing a function which should not be used outside of the module # pylint: disable=protected-access config_parser._parse_to_raw_lines("\n".join(line_list)) self.assertEqual(context_manager.exception.args[0], invalid_line_list)
def test_parse_lines_finishing_with_comment(self): self.assertEqual( [("site", "1.1.1.1")], # testing a function which should not be used outside of the module # pylint: disable=protected-access config_parser._parse_to_raw_lines("\n".join([ "site = '1.1.1.1' #comment", ])))
def test_skip_empty_lines(self): self.assertEqual( [("site", "1.1.1.1")], # testing a function which should not be used outside of the module # pylint: disable=protected-access config_parser._parse_to_raw_lines("\n".join([ " ", "site = 1.1.1.1", ])))
def test_parse_simple_correct_lines(self): self.assertEqual( [ ("site", "1.1.1.1"), ('site', '2.2.2.2'), ('arbitrator', '3.3.3.3'), ('syntactically_correct', 'nonsense'), ('line-with', 'hash#literal'), ], # testing a function which should not be used outside of the module # pylint: disable=protected-access config_parser._parse_to_raw_lines("\n".join([ "site = 1.1.1.1", " site = 2.2.2.2 ", "arbitrator=3.3.3.3", "syntactically_correct = nonsense", "line-with = hash#literal", "", ])))