@@ -163,10 +163,13 @@ def test_file_mvd_attr():
163163 ]
164164)
165165def test_invalid_headers_ (filename ):
166- # error in header
167- with pytest .raises (_ValidationError ) :
166+
167+ with pytest .raises (CollectedValidationErrors ) as exc_info :
168168 parse (filename = filename , with_tree = False , only_header = True )
169169
170+ errors = exc_info .value .errors
171+ assert len (errors ) > 0
172+
170173
171174@pytest .mark .parametrize (
172175 "filename" ,
@@ -177,22 +180,35 @@ def test_invalid_headers_(filename):
177180 ],
178181)
179182def test_valid_headers (filename ):
180- # error in body
183+
184+ # error are in body, not in the header
181185 with nullcontext ():
182186 parse (filename = filename , with_tree = False , only_header = True )
183187
184188
185- def test_header_entity_fields ():
186- with pytest .raises (_ValidationError ):
187- parse (
188- filename = "fixtures/fail_too_many_header_entity_fields.ifc" , only_header = True
189- )
189+ def test_too_many_header_entity_fields ():
190+ with pytest .raises (_ValidationError ) as exc_info :
191+ parse (filename = "fixtures/fail_too_many_header_entity_fields.ifc" , only_header = True )
192+
193+ errors = str (exc_info .value )
194+
195+ assert len (errors ) > 0
196+ assert "1 validation error(s) collected" in errors
197+ assert "Invalid number of parameters for HEADER field 'FILE_NAME'." in errors
198+ assert "Expected 7, found 8." in errors
190199
191200
192201def test_header_entity_fields_whole_file ():
193- with pytest .raises (_ValidationError ):
202+ with pytest .raises (_ValidationError ) as exc_info :
194203 parse (filename = "fixtures/fail_too_many_header_entity_fields.ifc" )
195204
205+ errors = str (exc_info .value )
206+
207+ assert len (errors ) > 0
208+ assert "1 validation error(s) collected" in errors
209+ assert "Invalid number of parameters for HEADER field 'FILE_NAME'." in errors
210+ assert "Expected 7, found 8." in errors
211+
196212
197213def test_multiple_duplicate_ids ():
198214 with pytest .raises (CollectedValidationErrors ) as exc_info :
@@ -202,7 +218,9 @@ def test_multiple_duplicate_ids():
202218
203219 assert len (errors ) == 2
204220 assert all (isinstance (e , DuplicateNameError ) for e in errors )
205-
221+ assert all ("On line" in str (e ) for e in errors )
222+ assert all ("Duplicate instance name" in str (e ) for e in errors )
223+
206224
207225def test_multiple_wrong_header_fields ():
208226 with pytest .raises (CollectedValidationErrors ) as exc_info :
@@ -212,6 +230,7 @@ def test_multiple_wrong_header_fields():
212230
213231 assert len (errors ) == 3
214232 assert all (isinstance (e , HeaderFieldError ) for e in errors )
233+ assert all ("Invalid number of parameters for HEADER field" in str (e ) for e in errors )
215234
216235
217236REPO_DIR = os .path .dirname (os .path .abspath (__file__ ))
0 commit comments