def testException (self): instance = None with self.assertRaises(pyxb.SimpleUnionValueError) as cm: instance = trac26.eUnionCard('pump') e = cm.exception self.assertEqual(e.type, trac26.tUnionCard) self.assertEqual(e.value, ('pump',)) self.assertTrue(e.location is None) self.assertEqual(str(e), "No memberType of tUnionCard can be constructed from ('pump',)")
def testSchemaSupport (self): for (ty, va) in ((trac26.tCardCymru, 'un'), (trac26.tCardEnglish, 'two') , (xs.int, 3)): instance = trac26.eUnionCard(va) self.assertTrue(isinstance(instance, ty)) xmlt = six.u('<eUnionCard>%s</eUnionCard>') % (va,) xmld = xmlt.encode('utf-8') self.assertEqual(xmld, instance.toxml('utf-8', root_only=True)) instance = trac26.CreateFromDocument(self.Good_xmlt) self.assertEqual(self.Good_xmld, instance.toxml('utf-8', root_only=True))
def testException(self): instance = None with self.assertRaises(pyxb.SimpleUnionValueError) as cm: instance = trac26.eUnionCard('pump') e = cm.exception self.assertEqual(e.type, trac26.tUnionCard) self.assertEqual(e.value, ('pump', )) self.assertTrue(e.location is None) self.assertEqual( str(e), "No memberType of tUnionCard can be constructed from ('pump',)")
def testSchemaSupport(self): for (ty, va) in ((trac26.tCardCymru, 'un'), (trac26.tCardEnglish, 'two'), (xs.int, 3)): instance = trac26.eUnionCard(va) self.assertTrue(isinstance(instance, ty)) xmlt = u'<eUnionCard>%s</eUnionCard>' % (va, ) xmld = xmlt.encode('utf-8') self.assertEqual(xmld, instance.toxml('utf-8', root_only=True)) instance = trac26.CreateFromDocument(self.Good_xmlt) self.assertEqual(self.Good_xmld, instance.toxml('utf-8', root_only=True))