Ejemplo n.º 1
0
 def testContainerAssignment(self):
     i = xs.string(self.body, _element=anything)
     instance = container()
     instance.anything = i
     explicit_xml = instance.toxml("utf-8")
     instance.anything = xs.string(self.body)
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
     instance.anything = xs.int(43)
     self.assertTrue(isinstance(instance.anything, xs.int))
     int_xml = instance.toxml("utf-8")
     instance.anything = self.body
     self.assertTrue(isinstance(instance.anything, xs.anyType))
     oc = instance.anything.orderedContent()
     self.assertEqual(1, len(oc))
     self.assertTrue(isinstance(oc[0],
                                pyxb.binding.basis.NonElementContent))
     xmlt = six.u('<container><anything>something</anything></container>')
     xmld = xmlt.encode('utf-8')
     self.assertEqual(xmld, instance.toxml('utf-8', root_only=True))
     instance.anything = 43
     self.assertTrue(isinstance(instance.anything, xs.anyType))
     oc = instance.anything.orderedContent()
     self.assertEqual(1, len(oc))
     self.assertTrue(isinstance(oc[0],
                                pyxb.binding.basis.NonElementContent))
     xmlt = six.u('<container><anything>43</anything></container>')
     xmld = xmlt.encode('utf-8')
     self.assertEqual(xmld, instance.toxml('utf-8', root_only=True))
Ejemplo n.º 2
0
 def testContainerAssignment (self):
     i = xs.string(self.body, _element=anything)
     instance = container()
     instance.anything = i
     explicit_xml = instance.toxml("utf-8")
     instance.anything = xs.string(self.body)
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
     instance.anything = xs.int(43)
     self.assertTrue(isinstance(instance.anything, xs.int))
     int_xml = instance.toxml("utf-8")
     instance.anything = self.body
     self.assertTrue(isinstance(instance.anything, xs.anyType))
     oc = instance.anything.orderedContent()
     self.assertEqual(1, len(oc))
     self.assertTrue(isinstance(oc[0], pyxb.binding.basis.NonElementContent))
     xmlt = six.u('<container><anything>something</anything></container>')
     xmld = xmlt.encode('utf-8')
     self.assertEqual(xmld, instance.toxml('utf-8', root_only=True))
     instance.anything = 43
     self.assertTrue(isinstance(instance.anything, xs.anyType))
     oc = instance.anything.orderedContent()
     self.assertEqual(1, len(oc))
     self.assertTrue(isinstance(oc[0], pyxb.binding.basis.NonElementContent))
     xmlt = six.u('<container><anything>43</anything></container>')
     xmld = xmlt.encode('utf-8')
     self.assertEqual(xmld, instance.toxml('utf-8', root_only=True))
Ejemplo n.º 3
0
 def testContainerCtor(self):
     i = xs.string(self.body, _element=anything)
     instance = container(anything=i)
     explicit_xml = instance.toxml("utf-8")
     instance = container(anything=xs.string(self.body))
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
Ejemplo n.º 4
0
 def testContainerCtor (self):
     i = xs.string(self.body, _element=anything)
     instance = container(anything=i)
     explicit_xml = instance.toxml("utf-8")
     instance = container(anything=xs.string(self.body))
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
Ejemplo n.º 5
0
 def testContainerAssignment (self):
     i = xs.string(self.body, _element=anything)
     instance = container()
     instance.anything = i
     explicit_xml = instance.toxml("utf-8")
     instance.anything = xs.string(self.body)
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
     instance.anything = xs.int(43)
     int_xml = instance.toxml("utf-8")
     instance.anything = self.body
     # You can do that, but you won't be able to convert it to xml
     self.assertRaises(AttributeError, instance.toxml)
     instance.anything = 43
     self.assertRaises(AttributeError, instance.toxml)
Ejemplo n.º 6
0
 def testContainerAssignment(self):
     i = xs.string(self.body, _element=anything)
     instance = container()
     instance.anything = i
     explicit_xml = instance.toxml("utf-8")
     instance.anything = xs.string(self.body)
     implicit_xml = instance.toxml("utf-8")
     self.assertEqual(explicit_xml, implicit_xml)
     instance.anything = xs.int(43)
     int_xml = instance.toxml("utf-8")
     instance.anything = self.body
     # You can do that, but you won't be able to convert it to xml
     self.assertRaises(AttributeError, instance.toxml)
     instance.anything = 43
     self.assertRaises(AttributeError, instance.toxml)
Ejemplo n.º 7
0
 def testToXML(self):
     instance = xs.string(self.body, _element=anything)
     self.assertEqual(instance.toxml("utf-8", root_only=True), self.xmld)
Ejemplo n.º 8
0
 def testPreserveString(self):
     cases = ["test", "  test", "  test", "\ttest", "\ttest\n\rtoo\n"]
     for c in cases:
         self.assertEqual(c, datatypes.string(c))
         self.assertEqual(c, datatypes.string(six.text_type(c)))
Ejemplo n.º 9
0
 def testToXML (self):
     instance = xs.string(self.body, _element=anything)
     self.assertEqual(instance.toxml("utf-8", root_only=True), self.xmld)
Ejemplo n.º 10
0
 def testPreserveString (self):
     cases = [ "test", "  test", "  test", "\ttest", "\ttest\n\rtoo\n" ]
     for c in cases:
         self.assertEqual(c, datatypes.string(c))
         self.assertEqual(c, datatypes.string(unicode(c)))