Пример #1
0
 def test_load_yaml_by_path_logs_and_returns_None_on_bad_syntax(
         self, which_bad, err):
     path = getattr(self, which_bad)
     e = err.format(p=path)
     assert YamlLoader.load_yaml_by_path(path) == None
     assert 'WARNING' == self.tlh.msgs[0][0]
     assert re.match(e, self.tlh.msgs[0][1])
Пример #2
0
 def test_load_yaml_by_path_logs_and_returns_None_on_bad_syntax(self):
     e = "Yaml error in {s} \(line 0, column 3\): mapping values are not allowed (in this context|here)".format(
         s=self.bad_syntax
     )
     assert YamlLoader.load_yaml_by_path(self.bad_syntax) == None
     assert "WARNING" == self.tlh.msgs[0][0]
     assert re.match(e, self.tlh.msgs[0][1])
Пример #3
0
    def check_yamls(cls, dap):
        '''Check that all assistants and snippets are valid.

        Return list of DapProblems.'''
        problems = list()

        for yaml in dap.assistants_and_snippets:
            path = yaml + '.yaml'
            parsed_yaml = YamlLoader.load_yaml_by_path(dap._get_file(path, prepend=True))
            if parsed_yaml:
                try:
                    yaml_checker.check(path, parsed_yaml)
                except YamlError as e:
                    problems.append(DapProblem(exc_as_decoded_string(e), level=logging.ERROR))
            else:
                problems.append(DapProblem('Empty YAML ' + path, level=logging.WARNING))

        return problems
Пример #4
0
    def check_yamls(cls, dap):
        '''Check that all assistants and snippets are valid.

        Return list of DapProblems.'''
        problems = list()

        for yaml in dap.assistants_and_snippets:
            path = yaml + '.yaml'
            parsed_yaml = YamlLoader.load_yaml_by_path(
                dap._get_file(path, prepend=True))
            if parsed_yaml:
                try:
                    yaml_checker.check(path, parsed_yaml)
                except YamlError as e:
                    problems.append(
                        DapProblem(exc_as_decoded_string(e),
                                   level=logging.ERROR))
            else:
                problems.append(
                    DapProblem('Empty YAML ' + path, level=logging.WARNING))

        return problems
Пример #5
0
 def test_load_yaml_by_path_logs_and_returns_None_on_bad_syntax(self, which_bad, err):
     path = getattr(self, which_bad)
     e = err.format(p=path)
     assert YamlLoader.load_yaml_by_path(path) == None
     assert 'WARNING' == self.tlh.msgs[0][0]
     assert re.match(e, self.tlh.msgs[0][1])
Пример #6
0
 def test_load_yaml_by_path_logs_and_returns_None_on_bad_syntax(self):
     e = 'Yaml error in {s} (line 0, column 3): mapping values are not allowed in this context'.\
             format(s=self.bad_syntax)
     assert YamlLoader.load_yaml_by_path(self.bad_syntax) == None
     assert ('WARNING', e) in self.tlh.msgs