@@ -142,7 +142,7 @@ def g_fail():
142
142
143
143
with self .assertRaisesRegex (
144
144
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" ,
146
146
):
147
147
csp .run (g_fail , starttime = datetime (2023 , 1 , 1 ))
148
148
@@ -264,23 +264,10 @@ def test_nonstrict_cannot_inherit_strict(self):
264
264
class StrictBase (csp .Struct , allow_unset = False ):
265
265
base_val : int
266
266
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
-
279
267
with self .assertRaisesRegex (ValueError , "non-strict inheritance of strict base" ):
280
- NonStrictChild2 (base_val = 3 , child_val1 = 4 , child_val2 = 5 )
281
268
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
284
271
285
272
def test_nonstrict_strict_nonstrict_inheritance_order (self ):
286
273
"""inheritance order NonStrict -> Strict -> NonStrict raises an error"""
@@ -291,11 +278,10 @@ class NonStrictBase(csp.Struct, allow_unset=True):
291
278
class StrictMiddle (NonStrictBase , allow_unset = False ):
292
279
middle_val : int
293
280
294
- class NonStrictChild (StrictMiddle , allow_unset = True ):
295
- child_val : Optional [int ] = None
296
-
297
281
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
299
285
300
286
def test_nested_struct_serialization (self ):
301
287
"""to_dict / from_dict work with nested strict & non-strict structs"""
@@ -344,7 +330,7 @@ def main_graph():
344
330
csp .print ("" , res )
345
331
346
332
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"
348
334
):
349
335
csp .build_graph (main_graph )
350
336
0 commit comments