def test_nested_dict_inside_list(): tags = Tags.from_text(LIST_DICT) data = parse_items(tags) assert data == [ "MyString", ["ListItem1", { "Key": "Value" }, "ListItem2"], "Tail", ]
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)
def test_nested_dict_as_dict_value(): tags = Tags.from_text(DICT2) data = parse_items(tags) assert data == ["MyString", {"Key1": {"Key2": "Value2"}}, "Tail"]
def test_nested_list_as_dict_value(): tags = Tags.from_text(DICT_LIST) data = parse_items(tags) assert data == ["MyString", {"Key": ["ListItem"]}, "Tail"]
def test_nested_list_inside_list(): tags = Tags.from_text(LIST2) data = parse_items(tags) assert data == ["MyString", ["ListItem1", ["ListItem2"]], "Tail"]
def test_top_level_dict(): tags = Tags.from_text(DICT1) data = parse_items(tags) assert data == ["MyString", {"Key1": "Value1"}, "Tail"]
def test_parse_vec3(self, tags): data = parse_items(tags)[3] assert data == (7, 8, 9) assert type(data) is Vec3
def test_top_level_list(): tags = Tags.from_text(LIST1) data = parse_items(tags) assert data == ["MyString", ["ListItem1"], "Tail"]
def test_parse_float(self, tags): data = parse_items(tags)[1] assert data == 3.1415 assert type(data) is float
def test_parse_int(self, tags): data = parse_items(tags)[2] assert data == 255 assert type(data) is int
def test_parse_str(self, tags): data = parse_items(tags)[0] assert data == "MyString" assert type(data) == str
def test_parse_all(self, tags): data = parse_items(tags) assert len(data) == 4
def test_compile_complex_structures(self, struct): tags = compile_user_record("TEST", struct) assert parse_items(tags[1:]) == struct
def test_compile_simple_types(self, value): tags = compile_user_record("TEST", [value]) assert parse_items(tags[1:]) == [value]
def test_invalid_group_code_raises_value_error(): tags = Tags.from_text("5\ninvalid\n") with pytest.raises(const.DXFValueError): parse_items(tags)