1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-25 02:02:11 +03:00

fixed xmlHasNsProp() bugs for defaulted from DTD attribs, added a specific

* tree.c python/tests/Makefile.am python/tests/attribs.py:
  fixed xmlHasNsProp() bugs for defaulted from DTD attribs,
  added a specific regression test
* python/generator.py: xmlHasNsProp() and xmlHasProp() shall
  not raise exceptions when failing to find the attribute.
Daniel
This commit is contained in:
Daniel Veillard
2002-03-07 22:21:56 +00:00
parent 90bc371716
commit ef6c46f805
5 changed files with 91 additions and 16 deletions

View File

@ -2,6 +2,7 @@ EXAMPLE_DIR = $(prefix)/share/doc/libxml2-python-$(LIBXML_VERSION)/examples
PYTESTS= \
build.py \
attribs.py \
tst.py \
tstxpath.py \
xpathext.py \

34
python/tests/attribs.py Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/python -u
import sys
import libxml2
# Memory debug specific
libxml2.debugMemory(1)
#
# Testing XML document serialization
#
doc = libxml2.parseDoc(
"""<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE test [
<!ELEMENT test (#PCDATA) >
<!ATTLIST test xmlns:abc CDATA #FIXED "http://abc.org" >
<!ATTLIST test abc:attr CDATA #FIXED "def" >
]>
<test />
""")
elem = doc.getRootElement()
attr = elem.hasNsProp('attr', 'http://abc.org')
if attr == None or attr.serialize()[:-1] != """<!ATTLIST test abc:attr CDATA #FIXED "def">""":
print "Failed to find defaulted attribute abc:attr"
sys.exit(1)
doc.freeDoc()
# Memory debug specific
libxml2.cleanupParser()
if libxml2.debugMemory(1) == 0:
print "OK"
else:
print "Memory leak %d bytes" % (libxml2.debugMemory(1))
libxml2.dumpMemory()