Esempio 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))
Esempio 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))
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio n. 7
0
 def testToXML(self):
     instance = xs.string(self.body, _element=anything)
     self.assertEqual(instance.toxml("utf-8", root_only=True), self.xmld)
Esempio 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)))
Esempio n. 9
0
 def testToXML (self):
     instance = xs.string(self.body, _element=anything)
     self.assertEqual(instance.toxml("utf-8", root_only=True), self.xmld)
Esempio 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)))