Exemple #1
0
    def docs(self, path):
        from ruyaml import YAML

        tyaml = YAML(typ='safe', pure=True)
        tyaml.register_class(YAMLData)
        tyaml.register_class(Python)
        tyaml.register_class(Output)
        tyaml.register_class(Assert)
        return list(tyaml.load_all(path))
Exemple #2
0
 def test_root_literal_multi_doc(self):
     yaml = YAML(typ='safe', pure=True)
     s1 = 'abc'
     s2 = 'klm'
     inp = """
     --- |-
     {}
     --- |
     {}
     """
     for idx, d1 in enumerate(yaml.load_all(inp.format(s1, s2))):
         print('d1:', d1)
         assert ['abc', 'klm\n'][idx] == d1
Exemple #3
0
    def test_multi_document_load(self, tmpdir):
        """this went wrong on 3.7 because of StopIteration, PR 37 and Issue 211"""
        from ruyaml import YAML

        fn = Path(str(tmpdir)) / 'test.yaml'
        fn.write_text(
            textwrap.dedent(
                """\
            ---
            - a
            ---
            - b
            ...
            """
            )
        )
        yaml = YAML()
        assert list(yaml.load_all(fn)) == [['a'], ['b']]