Example #1
0
 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',)")
Example #2
0
 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))
Example #3
0
 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',)")
Example #4
0
 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))