示例#1
0
    def testSchemaSupport (self):
        cym1 = trac26.eConcCardCymru('un')
        eng3 = trac26.eConcCardEnglish('three')

        # Incremental through owning element
        instance = trac26.eCardinals()
        self.assertEqual(0, len(instance.eAbstractCard))
        instance.append(cym1)
        self.assertEqual(1, len(instance.eAbstractCard))
        self.assertTrue(isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        instance.append(eng3)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
        xmld = instance.toxml('utf-8', root_only=True)
        self.assertEqual(xmld, self.Good_xmld)

        # Incremental through construtor element
        instance = trac26.eCardinals(cym1, eng3)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        self.assertTrue(isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
        xmld = instance.toxml('utf-8', root_only=True)
        self.assertEqual(xmld, self.Good_xmld)

        # Through parsing
        instance = trac26.CreateFromDocument(self.Good_xmlt)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        self.assertTrue(isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
示例#2
0
    def testSchemaSupport(self):
        cym1 = trac26.eConcCardCymru('un')
        eng3 = trac26.eConcCardEnglish('three')

        # Incremental through owning element
        instance = trac26.eCardinals()
        self.assertEqual(0, len(instance.eAbstractCard))
        instance.append(cym1)
        self.assertEqual(1, len(instance.eAbstractCard))
        self.assertTrue(
            isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        instance.append(eng3)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(
            isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
        xmld = instance.toxml('utf-8', root_only=True)
        self.assertEqual(xmld, self.Good_xmld)

        # Incremental through construtor element
        instance = trac26.eCardinals(cym1, eng3)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(
            isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        self.assertTrue(
            isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
        xmld = instance.toxml('utf-8', root_only=True)
        self.assertEqual(xmld, self.Good_xmld)

        # Through parsing
        instance = trac26.CreateFromDocument(self.Good_xmlt)
        self.assertEqual(2, len(instance.eAbstractCard))
        self.assertTrue(
            isinstance(instance.eAbstractCard[0], trac26.tCardCymru))
        self.assertTrue(
            isinstance(instance.eAbstractCard[1], trac26.tCardEnglish))
        self.assertTrue(instance.validateBinding())
示例#3
0
 def testIncremental(self):
     # Without type information, incremental does not work.  The content
     # model fails to recognize it, and it looks like mixed content.
     instance = trac26.eCardinals()
     self.assertEqual(0, len(instance.eAbstractCard))
     self.assertRaises(pyxb.MixedContentError, instance.append, 'un')
示例#4
0
 def testIncremental (self):
     # Without type information, incremental does not work.  The content
     # model fails to recognize it, and it looks like mixed content.
     instance = trac26.eCardinals()
     self.assertEqual(0, len(instance.eAbstractCard))
     self.assertRaises(pyxb.MixedContentError, instance.append, 'un')