@@ -1018,7 +1018,7 @@ def test_crop_sofa_string_transitive_references_remain(small_typesystem_xml):
10181018 cas = Cas (typesystem = typesystem )
10191019
10201020 # Create parent and child types and a feature on parent referencing child
1021- typesystem .create_type ("test.Child" )
1021+ Child = typesystem .create_type ("test.Child" )
10221022 Parent = typesystem .create_type ("test.Parent" )
10231023 typesystem .create_feature ("test.Parent" , "child" , "test.Child" )
10241024
@@ -1179,6 +1179,50 @@ def test_deep_copy_none_non_primitive_feature():
11791179 assert getattr (copied_parent , "child" ) is None
11801180
11811181
1182+ def test_deep_copy_none_fsarray_feature ():
1183+ """Ensure an FSArray feature set to None is preserved in the copy."""
1184+ typesystem = TypeSystem ()
1185+ Foo = typesystem .create_type ("test.Foo" )
1186+ typesystem .create_feature (
1187+ Foo ,
1188+ "arr" ,
1189+ rangeType = typesystem .get_type ("uima.cas.FSArray" ),
1190+ elementType = typesystem .get_type (TYPE_NAME_TOP ),
1191+ multipleReferencesAllowed = True ,
1192+ )
1193+
1194+ cas = Cas (typesystem = typesystem )
1195+ foo = Foo ()
1196+ foo .arr = None
1197+ cas .add (foo )
1198+
1199+ copy = cas .deep_copy (copy_typesystem = False )
1200+ copied_foo = list (copy .select ("test.Foo" ))[0 ]
1201+ assert getattr (copied_foo , "arr" ) is None
1202+
1203+
1204+ def test_deep_copy_none_primitive_collection_feature ():
1205+ """Ensure a primitive collection feature set to None is preserved in the copy."""
1206+ typesystem = TypeSystem ()
1207+ Foo = typesystem .create_type ("test.Foo" )
1208+ typesystem .create_feature (
1209+ Foo ,
1210+ "ints" ,
1211+ rangeType = typesystem .get_type (TYPE_NAME_INTEGER_ARRAY ),
1212+ elementType = typesystem .get_type (TYPE_NAME_INTEGER ),
1213+ multipleReferencesAllowed = True ,
1214+ )
1215+
1216+ cas = Cas (typesystem = typesystem )
1217+ foo = Foo ()
1218+ foo .ints = None
1219+ cas .add (foo )
1220+
1221+ copy = cas .deep_copy (copy_typesystem = False )
1222+ copied_foo = list (copy .select ("test.Foo" ))[0 ]
1223+ assert getattr (copied_foo , "ints" ) is None
1224+
1225+
11821226def test_deep_copy_empty_array ():
11831227 """Ensure empty FSArray is preserved as empty in the copy."""
11841228 typesystem = TypeSystem ()
0 commit comments