[Lxml-checkins] r43535 - lxml/trunk/src/lxml/tests
scoder at codespeak.net
scoder at codespeak.net
Mon May 21 18:03:23 CEST 2007
Author: scoder
Date: Mon May 21 18:03:22 2007
New Revision: 43535
Modified:
lxml/trunk/src/lxml/tests/test_objectify.py
Log:
test cases for XSI annotations in objectify
Modified: lxml/trunk/src/lxml/tests/test_objectify.py
==============================================================================
--- lxml/trunk/src/lxml/tests/test_objectify.py (original)
+++ lxml/trunk/src/lxml/tests/test_objectify.py Mon May 21 18:03:22 2007
@@ -13,6 +13,7 @@
from lxml import objectify
+XML_SCHEMA_NS = "http://www.w3.org/2001/XMLSchema"
XML_SCHEMA_INSTANCE_NS = "http://www.w3.org/2001/XMLSchema-instance"
XML_SCHEMA_INSTANCE_TYPE_ATTR = "{%s}type" % XML_SCHEMA_INSTANCE_NS
XML_SCHEMA_NIL_ATTR = "{%s}nil" % XML_SCHEMA_INSTANCE_NS
@@ -497,6 +498,23 @@
root.b = False
self.assertFalse(root.b)
+ def test_dataelement_xsi(self):
+ el = objectify.DataElement(1, _xsi="string")
+ self.assertEquals(
+ el.get(XML_SCHEMA_INSTANCE_TYPE_ATTR),
+ 'xsd:string')
+
+ def test_dataelement_xsi_nsmap(self):
+ el = objectify.DataElement(1, _xsi="string",
+ nsmap={'schema': XML_SCHEMA_NS})
+ self.assertEquals(
+ el.get(XML_SCHEMA_INSTANCE_TYPE_ATTR),
+ 'schema:string')
+
+ def test_dataelement_xsi_prefix_error(self):
+ self.assertRaises(ValueError, objectify.DataElement, 1,
+ _xsi="foo:string")
+
def test_pytype_annotation(self):
XML = self.XML
root = XML(u'''\
More information about the lxml-checkins
mailing list