Example #1
0
def test_nested_dict_inside_list():
    tags = Tags.from_text(LIST_DICT)
    data = parse_items(tags)
    assert data == [
        "MyString",
        ["ListItem1", {
            "Key": "Value"
        }, "ListItem2"],
        "Tail",
    ]
Example #2
0
def test_missing_close_tag_raises_dxf_structure_error():
    tags = Tags.from_text("302\n[\n1\nListItem1")
    with pytest.raises(const.DXFStructureError):
        parse_items(tags)
Example #3
0
def test_nested_dict_as_dict_value():
    tags = Tags.from_text(DICT2)
    data = parse_items(tags)
    assert data == ["MyString", {"Key1": {"Key2": "Value2"}}, "Tail"]
Example #4
0
def test_nested_list_as_dict_value():
    tags = Tags.from_text(DICT_LIST)
    data = parse_items(tags)
    assert data == ["MyString", {"Key": ["ListItem"]}, "Tail"]
Example #5
0
def test_nested_list_inside_list():
    tags = Tags.from_text(LIST2)
    data = parse_items(tags)
    assert data == ["MyString", ["ListItem1", ["ListItem2"]], "Tail"]
Example #6
0
def test_top_level_dict():
    tags = Tags.from_text(DICT1)
    data = parse_items(tags)
    assert data == ["MyString", {"Key1": "Value1"}, "Tail"]
Example #7
0
 def test_parse_vec3(self, tags):
     data = parse_items(tags)[3]
     assert data == (7, 8, 9)
     assert type(data) is Vec3
Example #8
0
def test_top_level_list():
    tags = Tags.from_text(LIST1)
    data = parse_items(tags)
    assert data == ["MyString", ["ListItem1"], "Tail"]
Example #9
0
 def test_parse_float(self, tags):
     data = parse_items(tags)[1]
     assert data == 3.1415
     assert type(data) is float
Example #10
0
 def test_parse_int(self, tags):
     data = parse_items(tags)[2]
     assert data == 255
     assert type(data) is int
Example #11
0
 def test_parse_str(self, tags):
     data = parse_items(tags)[0]
     assert data == "MyString"
     assert type(data) == str
Example #12
0
 def test_parse_all(self, tags):
     data = parse_items(tags)
     assert len(data) == 4
Example #13
0
 def test_compile_complex_structures(self, struct):
     tags = compile_user_record("TEST", struct)
     assert parse_items(tags[1:]) == struct
Example #14
0
 def test_compile_simple_types(self, value):
     tags = compile_user_record("TEST", [value])
     assert parse_items(tags[1:]) == [value]
Example #15
0
def test_invalid_group_code_raises_value_error():
    tags = Tags.from_text("5\ninvalid\n")
    with pytest.raises(const.DXFValueError):
        parse_items(tags)