@@ -142,7 +142,7 @@ def g_fail():
142142
143143 with self .assertRaisesRegex (
144144 AttributeError ,
145- "Cannot access optional field 'opt_str' on object 'MyStrictStruct' at graph time" ,
145+ "Cannot access optional field 'opt_str' on strict struct object 'MyStrictStruct' at graph time" ,
146146 ):
147147 csp .run (g_fail , starttime = datetime (2023 , 1 , 1 ))
148148
@@ -264,23 +264,10 @@ def test_nonstrict_cannot_inherit_strict(self):
264264 class StrictBase (csp .Struct , allow_unset = False ):
265265 base_val : int
266266
267- class NonStrictChild1 (StrictBase , allow_unset = True ):
268- child_val1 : Optional [int ] = None
269-
270- class NonStrictChild2 (NonStrictChild1 , allow_unset = True ):
271- child_val2 : Optional [int ] = None
272-
273- class NonStrictChild3 (NonStrictChild2 , allow_unset = True ):
274- child_val3 : Optional [int ] = None
275-
276- with self .assertRaisesRegex (ValueError , "non-strict inheritance of strict base" ):
277- NonStrictChild1 (base_val = 1 , child_val1 = 2 )
278-
279267 with self .assertRaisesRegex (ValueError , "non-strict inheritance of strict base" ):
280- NonStrictChild2 (base_val = 3 , child_val1 = 4 , child_val2 = 5 )
281268
282- with self . assertRaisesRegex ( ValueError , "non-strict inheritance of strict base" ):
283- NonStrictChild3 ( base_val = 6 , child_val1 = 7 , child_val2 = 8 , child_val3 = 9 )
269+ class NonStrictChild1 ( StrictBase , allow_unset = True ):
270+ child_val1 : Optional [ int ] = None
284271
285272 def test_nonstrict_strict_nonstrict_inheritance_order (self ):
286273 """inheritance order NonStrict -> Strict -> NonStrict raises an error"""
@@ -291,11 +278,10 @@ class NonStrictBase(csp.Struct, allow_unset=True):
291278 class StrictMiddle (NonStrictBase , allow_unset = False ):
292279 middle_val : int
293280
294- class NonStrictChild (StrictMiddle , allow_unset = True ):
295- child_val : Optional [int ] = None
296-
297281 with self .assertRaisesRegex (ValueError , "non-strict inheritance of strict base" ):
298- NonStrictChild (base_val = 1 , middle_val = 2 , child_val = 3 )
282+
283+ class NonStrictChild (StrictMiddle , allow_unset = True ):
284+ child_val : Optional [int ] = None
299285
300286 def test_nested_struct_serialization (self ):
301287 """to_dict / from_dict work with nested strict & non-strict structs"""
@@ -344,7 +330,7 @@ def main_graph():
344330 csp .print ("" , res )
345331
346332 with self .assertRaisesRegex (
347- AttributeError , "Cannot access optional field 'is_active' on object 'Test' at graph time"
333+ AttributeError , "Cannot access optional field 'is_active' on strict struct object 'Test' at graph time"
348334 ):
349335 csp .build_graph (main_graph )
350336
0 commit comments