Exemple #1
0
 def test_none_data_to_get_nodes_by_path_segment(self, capsys, quiet_logger):
     import sys
     yamldata = ""
     yaml = YAML()
     data = yaml.load(yamldata)
     processor = Processor(quiet_logger, data)
     nodes = list(processor._get_nodes_by_path_segment(data, YAMLPath("abc"), 0))
     yaml.dump(data, sys.stdout)
     assert -1 == capsys.readouterr().out.find("abc")
Exemple #2
0
    def test_get_nodes_by_unknown_path_segment_error(self, quiet_logger):
        from collections import deque
        from enum import Enum
        from yamlpath.enums import PathSegmentTypes
        names = [m.name for m in PathSegmentTypes] + ['DNF']
        PathSegmentTypes = Enum('PathSegmentTypes', names)

        yamldata = """---
        key: value
        """
        yaml = YAML()
        data = yaml.load(yamldata)
        processor = Processor(quiet_logger, data)
        path = YAMLPath("abc")
        stringified = str(path)     # Force Path to parse
        path._escaped = deque([
            (PathSegmentTypes.DNF, "abc"),
        ])

        with pytest.raises(NotImplementedError):
            nodes = list(processor._get_nodes_by_path_segment(data, path, 0))