@@ -140,8 +140,31 @@ class RootModel(BaseXmlModel, tag="model"):
140
140
assert_xml_equal (actual_xml , xml )
141
141
142
142
143
+ def test_attr_list_extraction ():
144
+ class RootModel (BaseXmlModel , tag = "model" ):
145
+ values : List [float ] = attr ()
146
+
147
+ xml = '''
148
+ <model values="3.14 -1.0 300.0"/>
149
+ '''
150
+ # This will fail if scientific notation is used
151
+ # i.e. if 300 is replaced with 3e2 or 300, the deserializer
152
+ # will always use the standard notation with the added `.0`.
153
+ # While this behaviour fails the tests, it shouldn't
154
+ # matter in practice.
155
+
156
+ actual_obj = RootModel .from_xml (xml )
157
+ expected_obj = RootModel (
158
+ values = [3.14 , - 1.0 , 3e2 ]
159
+ )
160
+
161
+ assert actual_obj == expected_obj
162
+
163
+ actual_xml = actual_obj .to_xml ()
164
+ assert_xml_equal (actual_xml , xml )
165
+
166
+
143
167
def test_homogeneous_definition_errors ():
144
- breakpoint ()
145
168
with pytest .raises (errors .ModelFieldError ):
146
169
class TestModel (BaseXmlModel ):
147
170
attr1 : List [Tuple [int , ...]]
@@ -179,3 +202,4 @@ class TestSubModel(BaseXmlModel):
179
202
180
203
class TestModel (BaseXmlModel ):
181
204
text : List [TestSubModel ]
205
+
0 commit comments