def test_setListVal_Fail(self): typeSystemFilePath = 'typesystem.xml' typesystem = TypeSystemFactory.readTypeSystem(self, typeSystemFilePath) fstype4 = typesystem.getType( 'de.tudarmstadt.ukp.dkpro.core.api.metadata.type.TagDescription') fsTagDesc1 = TOP(fstype4, 1, typesystem) aFeature = Feature(fsTagDesc1.FStype, 'name') aFeature.description = '' aFeature.rangeType = 'uima.cas.String' listval = [] listval.append('#') self.assertEqual('', '') with self.assertRaises(TypeError): nonlist = 1 fsTagDesc1.setListValue(aFeature, aFeature.rangeType, nonlist) with self.assertRaises(TypeError): nonfeature = 1 fsTagDesc1.setListValue(nonfeature, aFeature.rangeType, listval) with self.assertRaises(TypeError): aFeature.rangeType = 'uima.cas.Inetger' fsTagDesc1.setListValue(aFeature, aFeature.rangeType, listval) with self.assertRaises(TypeError): aFeature.rangeType = typesystem.getType( 'de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS') fsTagDesc1.setListValue(aFeature, aFeature.rangeType, listval) with self.assertRaises(TypeError): aFeature.rangeType = 'uima.cas.Integer' aFeature.elementType = 'uima.cas.String' fsTagDesc1.setListValue(aFeature, aFeature.elementType, listval)
def test_ListValsetNget(self): typeSystemFilePath = 'typesystem.xml' typesystem = TypeSystemFactory.readTypeSystem(self, typeSystemFilePath) fstype4 = typesystem.getType( 'de.tudarmstadt.ukp.dkpro.core.api.metadata.type.TagDescription') fsTagDesc1 = TOP(fstype4, 1, typesystem) aFeature = Feature(fsTagDesc1.FStype, 'name') aFeature.description = '' aFeature.rangeType = 'uima.cas.String' listval = [] listval.append('#') fsTagDesc1.setListValue(aFeature, aFeature.rangeType, listval) self.assertEqual(' '.join(fsTagDesc1.getListValue(aFeature)), '#')