示例#1
0
def test_normalized_path_strings(path_string):
    assert str(Path(path_string)) == path_string
示例#2
0
def test_path_with_named_keys(path_string, keys):
    assert tuple(p.key for p in Path(path_string)) == keys
示例#3
0
def test_path_set(biglist, path, select, results):
    del biglist[Path(path)]
    assert biglist.get_all(Path(select)) == results
示例#4
0
def test_path_set(biglist, path, value, select, results):
    biglist[Path(path)] = parse_nbt(value)
    assert biglist.get_all(Path(select)) == results
示例#5
0
def test_path_get_biglist(biglist, path, items):
    assert biglist.get_all(Path(path)) == items
示例#6
0
    '[{}]',
] + [
    path for entries in [bigtest_path_to_items, biglist_path_to_items]
    for path, _ in entries
] + [path for path, _, _, _ in path_set_and_get] + [
    path for _, _, path, _ in path_set_and_get
] + [path for path, _, _ in path_del_and_get
     ] + [path for _, path, _ in path_del_and_get]


@pytest.mark.parametrize('path_string', normalized_path_strings)
def test_normalized_path_strings(path_string):
    assert str(Path(path_string)) == path_string


equivalent_paths = [[Path(p) for p in paths] for paths in [
    [
        'a.b.c', 'a b c', 'a. b. c', '"a""b""c"', ' "a"  ..  "b" .c  ',
        'a\nb\nc'
    ],
    [
        '[]{a: 1}', '[{a: 1}]', '[{a: 1}]{}', '[{a: 42}]{a: 1}',
        '[{}]{a: 42}{}{a: 1}'
    ],
    [
        '{a: {foo: "bar"}, value: 0}',
        '{a: {foo: "bar"}, value: 0}{a: {foo: "bar"}}'
    ],
    [
        '{a: {b: {c: 1}, foo: 42}}', '{a: {b: {c: 1}}}{a: {foo: 42}}',
        '{a: {b: {c: "thing"}, foo: 42}}{a: {b: {c: 1}}}'
示例#7
0
    ]
    + [path for path, _, _, _ in path_set_and_get]
    + [path for _, _, path, _ in path_set_and_get]
    + [path for path, _, _ in path_del_and_get]
    + [path for _, path, _ in path_del_and_get]
)


@pytest.mark.parametrize("path_string", normalized_path_strings)
def test_normalized_path_strings(path_string):
    assert str(Path(path_string)) == path_string


# fmt: off
equivalent_paths = [
    [Path(p) for p in paths]
    for paths in [
        ["a.b.c", "a b c", "a. b. c", '"a""b""c"', ' "a"  ..  "b" .c  ', "a\nb\nc"],
        ["[]{a: 1}", "[{a: 1}]", "[{a: 1}]{}", "[{a: 42}]{a: 1}", "[{}]{a: 42}{}{a: 1}"],
        ['{a: {foo: "bar"}, value: 0}', '{a: {foo: "bar"}, value: 0}{a: {foo: "bar"}}'],
        ["{a: {b: {c: 1}, foo: 42}}", "{a: {b: {c: 1}}}{a: {foo: 42}}", '{a: {b: {c: "thing"}, foo: 42}}{a: {b: {c: 1}}}'],
        ["a[5]", "a[05]", "a[00005]"],
    ]
]
# fmt: on


equivalent_path_pairs = [
    (path1, path2)
    for paths in equivalent_paths
    for path1, path2 in zip(paths, paths[1:])