How to use the yamlpath.path.Path function in yamlpath

To help you get started, we’ve selected a few yamlpath examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_parse_double_inversion_error(self):
        with pytest.raises(YAMLPathException) as ex:
            str(Path("abc[!def!=ghi]"))
        assert -1 < str(ex.value).find("Double search inversion is meaningless")
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_parse_missing_operand_errors(self, input):
        with pytest.raises(YAMLPathException) as ex:
            str(Path(input))
        assert -1 < str(ex.value).find("Missing search operand")
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_parse_unmatched_regex_error(self):
        with pytest.raises(YAMLPathException) as ex:
            str(Path("abc[def=~/ghi]"))
        assert -1 < str(ex.value).find("contains an unterminated Regular Expression")
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_seperator_change(self):
        # IMPORTANT:  The YAML Path is only lazily parsed!  This means parsing
        # ONLY happens when the path is in some way used.  Casting it to string
        # qualifies as one form of use, so this test will instigate parsing via
        # stringification.  THIS MATTERS WHEN YOUR INTENTION IS TO **CHANGE**
        # THE PATH SEPERATOR!  So, if an original path uses dot-notation and
        # you wish to change it to forward-slash-notation, you must first cause
        # the original to become parsed, AND THEN change the seperator.
        testpath = Path("abc.def")
        dotted = str(testpath)
        testpath.seperator = PathSeperators.FSLASH
        assert "/abc/def" == str(testpath) != dotted
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_parse_unmatched_collector_error(self):
        with pytest.raises(YAMLPathException) as ex:
            str(Path("(abc"))
        assert -1 < str(ex.value).find("contains an unmatched () collector")
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_repr(self):
        assert repr(Path("abc.123")) == "Path('abc.123', '.')"
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_parse_unmatched_demarcation_error(self):
        with pytest.raises(YAMLPathException) as ex:
            str(Path("abc.'def"))
        assert -1 < str(ex.value).find("contains at least one unmatched demarcation mark")
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_escaped(self):
        testpath = Path(r"abc.def\.ghi")
        assert list(testpath.escaped) == [
            (PathSegmentTypes.KEY, "abc"),
            (PathSegmentTypes.KEY, "def.ghi"),
        ]
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_str(self, yamlpath, pathsep, output):
        # Test twice to include cache hits
        testpath = Path(yamlpath, pathsep)
        assert output == str(testpath) == str(testpath)
github wwkimball / yamlpath / tests / test_path_path.py View on Github external
def test_parse_bad_tilde_error(self):
        with pytest.raises(YAMLPathException) as ex:
            str(Path("abc[def~ghi]"))
        assert -1 < str(ex.value).find("Unexpected use of ~ operator")