Beispiel #1
0
def test_multiples_key_value():
    lines = [
        "key1\tvalue1",
        "key2\tvalue2",
        "key3\tvalue3",
        "key4\tvalue4",
    ]
    assert pytaml.parse_lines(lines) == [
        ("key1", "value1"),
        ("key2", "value2"),
        ("key3", "value3"),
        ("key4", "value4"),
    ]
Beispiel #2
0
def test_complex():
    lines = [
        "root",
        "\tkey1\t\tvalue1",
        "\tkey2\t\tvalue2",
        "\tkey3",
        "\t\titem1",
        "\t\titem2",
        "\t\titem3",
        "\t\titem4",
        "\t\t\tkey41\t\t\tvalue41",
        "\t\t\tkey42\t\t\tvalue42",
        "\t\t\tkey43\t\t\tvalue43",
        "\t\t\tkey44\t\t\tvalue44",
    ]
    assert pytaml.parse_lines(lines) == [(
        "root",
        [
            ("key1", "value1"),
            ("key2", "value2"),
            (
                "key3",
                [
                    "item1",
                    "item2",
                    "item3",
                    (
                        "item4",
                        [
                            ("key41", "value41"),
                            ("key42", "value42"),
                            ("key43", "value43"),
                            ("key44", "value44"),
                        ],
                    ),
                ],
            ),
        ],
    )]
Beispiel #3
0
def test_two_lists():
    lines = ["root1", "\titem1", "\titem2", "root2", "\titem3", "\titem4"]
    assert pytaml.parse_lines(lines) == [("root1", ["item1", "item2"]),
                                         ("root2", ["item3", "item4"])]
Beispiel #4
0
def test_key_value():
    lines = ["key\tvalue"]
    assert pytaml.parse_lines(lines) == [("key", "value")]
Beispiel #5
0
def test_list_at_first_level():
    lines = ["root", "\titem1", "\titem2"]
    assert pytaml.parse_lines(lines) == [("root", ["item1", "item2"])]
Beispiel #6
0
def test_list_at_root():
    lines = ["item1", "item2"]
    assert pytaml.parse_lines(lines) == ["item1", "item2"]