Exemplo n.º 1
0
def test_string_type():
    val = str2nbt("hello")
    assert isinstance(val, nbt.TAG_String)
    assert val.value == "hello"
    val = str2nbt('"hello"')
    assert isinstance(val, nbt.TAG_String)
    assert val.value == "hello"
Exemplo n.º 2
0
def test_compound_type():
    val = str2nbt("{a:1,b:2}")
    assert isinstance(val, nbt.TAG_Compound)
    assert type(val.tags[0]) == nbt.TAG_Int
    assert all(isinstance(t, nbt.TAG_Int) for t in val.tags)
    assert len(val.tags) == 2
    assert [t.name for t in val.tags] == ["a", "b"]
    assert [t.value for t in val.tags] == [1, 2]
Exemplo n.º 3
0
def test_list_type():
    lst = ["this", "is", "a", "string", "list"]
    lst_txt = "[" + ",".join(lst) + "]"
    val = str2nbt(lst_txt)
    assert isinstance(val, nbt.TAG_List)
    assert val.tagID == nbt.TAG_String.id
    assert all(isinstance(t, nbt.TAG_String) for t in val.tags)
    assert [t.value for t in val.tags] == lst
Exemplo n.º 4
0
def test_array_types(text, tag_type, value):
    val = str2nbt(text)
    assert isinstance(val, tag_type)
    assert val.value == value