def test_ComplexValsetNget(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.elementType = 'uima.cas.String' fsTagDesc1.setComplexValue(aFeature, 1j) self.assertEqual(complex(fsTagDesc1.getComplexValue(aFeature)), 1j)
def test_setComplexVal_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.elementType = 'uima.cas.String' self.assertEqual('', '') with self.assertRaises(TypeError): fsTagDesc1.setComplexValue(aFeature, 10.1) with self.assertRaises(TypeError): nonfeature = 1 fsTagDesc1.setComplexValue(nonfeature, 1j) with self.assertRaises(TypeError): aFeature.elementType = None fsTagDesc1.setComplexValue(aFeature, 1j) with self.assertRaises(TypeError): aFeature.elementType = 'uima.cas.Integer' fsTagDesc1.setComplexValue(aFeature, 1j)