Logo Search packages:      
Sourcecode: zope-parsedxml version File versions

ParsedXML::tests::domapi::CoreLvl2::DocumentFragmentReadTestCase Class Reference

Inheritance diagram for ParsedXML::tests::domapi::CoreLvl2::DocumentFragmentReadTestCase:

List of all members.


Detailed Description

def setUp(self): self.document = self.parse(""" <!DOCTYPE prefix:doc [ <!ELEMENT prefix:doc EMPTY> <!ATTLIST prefix:doc prefix:foo CDATA "bar"> ]> <prefix:doc xmlns:prefix="s"/> """ % TEST_NAMESPACE)

def checkHasAttributeNS(self): el = self.document.documentElement assert el.hasAttributeNS(TEST_NAMESPACE, 'foo'), ( 'Default attribute not found.') def checkGetAttributeNS(self): el = self.document.documentElement assert el.getAttributeNS(TEST_NAMESPACE, 'foo') == 'bar', ( "Wrong value of default attribute found, expected 'bar', " "found %s" % repr(el.getAttributeNS(TEST_NAMESPACE, 'foo'))) def checkCreateElementNS(self): el = self.document.createElementNS(TEST_NAMESPACE, 'doc') assert el.hasAttributeNS(TEST_NAMESPACE, 'foo'), ( 'Newly created Element Node should have default attribute.') assert el.getAttributeNS(TEST_NAMESPACE, 'foo') == 'bar', ( "Wrong value of default attribute found, expected 'bar', " "found %s" % el.getAttributeNS(TEST_NAMESPACE, 'foo')) checkAttribute(el.getAttributeNodeNS(TEST_NAMESPACE, 'foo'), 'specified', 0) def checkImportNodeToDefault(self): newDoc = self.implementation.createDocument(None, 'baz', None) newEl = newDoc.createElementNS(TEST_NAMESPACE, 'prefix:doc') el = self.document.importNode(newEl, 0) assert el.hasAttributeNS(TEST_NAMESPACE, 'foo'), ( 'Imported Element Node should have default attribute.') assert el.getAttributeNS(TEST_NAMESPACE, 'foo') == 'bar', ( "Wrong value of default attribute found, expected 'bar', " "found %s" % repr(el.getAttributeNS(TEST_NAMESPACE, 'foo'))) checkAttribute(el.getAttributeNodeNS(TEST_NAMESPACE, 'foo'), 'specified', 0) def checkChangePrefixUnspecified(self): attr = self.document.documentElement.getAttributeNodeNS(TEST_NAMESPACE, 'foo') attr.prefix = 'test' # Changing the prefix of a default attribute shouldn't make a new # unspecified (default) attribute node appear. # TODO: It turns out this may be a hole in the spec. See PXML(60)[]: # http://www.zope.org/Members/karl/ParsedXML/ParsedXMLTracker/60 # Waiting for consensus from DOM WG. Changing the prefix *should* make # a new Attr node appear it seems. I am not convinced yet. assert attr.ownerElement.attributes.length == 1, ( "Changing the prefix of a default attribute caused a new default " "attribute node to be created.") # The specified flag shouldn't change; we didn't change the value checkAttribute(attr, 'specified', 0) def checkChangePrefixSpecified(self): self.document.documentElement.setAttributeNS(TEST_NAMESPACE, 'foo', 'newValue') attr = self.document.documentElement.getAttributeNodeNS(TEST_NAMESPACE, 'foo') attr.prefix = 'test' # Changing the prefix of a specified attribute shouldn't make a new # unspecified (default) attribute node appear. assert attr.ownerElement.attributes.length == 2, ( "Changing the prefix of a specified attribute caused a new " "default attribute node to be created.") def checkRemoveAttributeNS(self): el = self.document.documentElement # Replace default with specified attr el.setAttributeNS(TEST_NAMESPACE, 'foo', 'baz') el.removeAttributeNS(TEST_NAMESPACE, 'foo') assert el.hasAttributeNS(TEST_NAMESPACE, 'foo'), ( 'Removing specified attribute should ' 'bring back default attribute.') assert el.getAttributeNS(TEST_NAMESPACE, 'foo') == 'bar', ( "Wrong value of default attribute foud, expected 'bar', " "found %s" % repr(el.getAttributeNS(TEST_NAMESPACE, 'foo'))) checkAttribute(el.getAttributeNodeNS(TEST_NAMESPACE, 'foo'), 'specified', 0) def checkRemoveAttributeNode(self): el = self.document.documentElement newAttr = self.document.createAttributeNS(TEST_NAMESPACE, 'foo') newAttr.value = 'baz' # Replace default with specified attr el.setAttributeNodeNS(newAttr) el.removeAttributeNode(newAttr) assert el.hasAttributeNS(TEST_NAMESPACE, 'foo'), ( 'Removing specified attribute should bring back default ' 'attribute.') assert el.getAttributeNS(TEST_NAMESPACE, 'foo') == 'bar', ( "Wrong value of default attribute found, expected 'bar', " "found %s" % repr(el.getAttributeNS(TEST_NAMESPACE, 'foo'))) checkAttribute(el.getAttributeNodeNS(TEST_NAMESPACE, 'foo'), 'specified', 0) def checkRemoveNamedItemNS(self): el = self.document.documentElement # Replace default with specified attr el.setAttributeNS(TEST_NAMESPACE, 'foo', 'baz') el.attributes.removeNamedItemNS(TEST_NAMESPACE, 'foo') assert el.hasAttributeNS(TEST_NAMESPACE, 'foo'), \ 'Removing specified attribute should bring back default attribute.' assert el.getAttributeNS(TEST_NAMESPACE, 'foo') == 'bar', ( "Wrong value of default attribute found, expected 'bar', found %s" % repr(el.getAttributeNS(TEST_NAMESPACE, 'foo'))) checkAttribute(el.getAttributeNodeNS(TEST_NAMESPACE, 'foo'), 'specified', 0) def checkSetAttributeNS(self): el = self.document.documentElement el.setAttributeNS(TEST_NAMESPACE, 'foo', 'baz') checkAttribute(el.getAttributeNodeNS(TEST_NAMESPACE, 'foo'), 'specified', 1) def checkSetAttributeNodeNS(self): el = self.document.documentElement newAttr = self.document.createAttributeNS(TEST_NAMESPACE, 'foo') newAttr.value = 'baz' el.setAttributeNode(newAttr) checkAttribute(el.getAttributeNodeNS(TEST_NAMESPACE, 'foo'), 'specified', 1)

Definition at line 1565 of file CoreLvl2.py.


Public Member Functions

def checkImportNode
def checkIsSupported
def checkLocalName
def checkNameSpaceURI
def checkOwnerDocument
def checkPrefix
def createDocument
def createDocumentNS
def hasAttributes
def setUp

Public Attributes

 docfrag
 document
 node

Static Public Attributes

 featureMatrix = _DOMImplCase.featureMatrix
string TEST_LOCAL_NAME = 'somelocalname'
 TEST_NAMESPACE = TEST_NAMESPACE
string TEST_PREFIX = 'aprefix'
string TEST_QUALIFIED_NAME = '%s:%s'

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index