@@ -1159,7 +1159,8 @@ public void WritesModelFactoryBodyForInheritedModels()
1159
1159
writer . Write ( method ) ;
1160
1160
var result = tw . ToString ( ) ;
1161
1161
Assert . Contains ( "try:" , result ) ;
1162
- Assert . Contains ( "mapping_value = parse_node.get_child_node(\" @odata.type\" ).get_str_value()" , result ) ;
1162
+ Assert . Contains ( "child_node = parse_node.get_child_node(\" @odata.type\" )" , result ) ;
1163
+ Assert . Contains ( "mapping_value = child_node.get_str_value() if child_node else None" , result ) ;
1163
1164
Assert . Contains ( "except AttributeError:" , result ) ;
1164
1165
Assert . Contains ( "mapping_value = None" , result ) ;
1165
1166
Assert . Contains ( "if mapping_value and mapping_value.casefold() == \" ns.childclass\" .casefold()" , result ) ;
@@ -1194,7 +1195,8 @@ public void WritesModelFactoryBodyForUnionModels()
1194
1195
writer . Write ( factoryMethod ) ;
1195
1196
var result = tw . ToString ( ) ;
1196
1197
Assert . Contains ( "try:" , result ) ;
1197
- Assert . Contains ( "mapping_value = parse_node.get_child_node(\" @odata.type\" ).get_str_value()" , result ) ;
1198
+ Assert . Contains ( "child_node = parse_node.get_child_node(\" @odata.type\" )" , result ) ;
1199
+ Assert . Contains ( "mapping_value = child_node.get_str_value() if child_node else None" , result ) ;
1198
1200
Assert . Contains ( "except AttributeError:" , result ) ;
1199
1201
Assert . Contains ( "mapping_value = None" , result ) ;
1200
1202
Assert . Contains ( "result = UnionTypeWrapper()" , result ) ;
0 commit comments