(root)/
libxml2-2.12.3/
python/
tests/
attribs.py
       1  #!/usr/bin/env python3
       2  import sys
       3  import setup_test
       4  import libxml2
       5  
       6  # Memory debug specific
       7  libxml2.debugMemory(1)
       8  
       9  #
      10  # Testing XML document serialization
      11  #
      12  doc = libxml2.parseDoc(
      13  """<?xml version="1.0" encoding="iso-8859-1"?>
      14  <!DOCTYPE test [
      15  <!ELEMENT test (#PCDATA) >
      16  <!ATTLIST test xmlns:abc CDATA #FIXED "http://abc.org" >
      17  <!ATTLIST test abc:attr CDATA #FIXED "def" >
      18  ]>
      19  <test />
      20  """)
      21  elem = doc.getRootElement()
      22  attr = elem.hasNsProp('attr', 'http://abc.org')
      23  if attr == None or attr.serialize()[:-1] != """<!ATTLIST test abc:attr CDATA #FIXED "def">""":
      24      print("Failed to find defaulted attribute abc:attr")
      25      sys.exit(1)
      26  
      27  doc.freeDoc()
      28  
      29  # Memory debug specific
      30  libxml2.cleanupParser()
      31  if libxml2.debugMemory(1) == 0:
      32      print("OK")
      33  else:
      34      print("Memory leak %d bytes" % (libxml2.debugMemory(1)))