diff options
author | Mike Hommey <glandium@debian.org> | 2005-07-12 19:58:48 +0000 |
---|---|---|
committer | Mike Hommey <glandium@debian.org> | 2005-07-12 19:58:48 +0000 |
commit | 112cb5bb5475afec1c1cbf1d6728ce4880d0fee8 (patch) | |
tree | 6c34596134f8665ebc180f29b50915dc70bbe5c1 /python/tests | |
parent | 0fc063df3ab2ad380d532d210dd1001de473e51b (diff) | |
download | libxml2-112cb5bb5475afec1c1cbf1d6728ce4880d0fee8.tar.gz |
Load /tmp/tmp.zfIyNk/libxml2-2.6.20 intoupstream/2.6.20
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'python/tests')
-rw-r--r-- | python/tests/Makefile.am | 1 | ||||
-rw-r--r-- | python/tests/Makefile.in | 2 | ||||
-rwxr-xr-x | python/tests/nsdel.py | 62 |
3 files changed, 65 insertions, 0 deletions
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am index c6d03e9..3571abf 100644 --- a/python/tests/Makefile.am +++ b/python/tests/Makefile.am @@ -30,6 +30,7 @@ PYTESTS= \ reader8.py \ readernext.py \ walker.py \ + nsdel.py \ ctxterror.py\ readererr.py\ relaxng.py \ diff --git a/python/tests/Makefile.in b/python/tests/Makefile.in index 6769fa1..a344e07 100644 --- a/python/tests/Makefile.in +++ b/python/tests/Makefile.in @@ -58,6 +58,7 @@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BASE_THREAD_LIBS = @BASE_THREAD_LIBS@ C14N_OBJ = @C14N_OBJ@ CATALOG_OBJ = @CATALOG_OBJ@ CC = @CC@ @@ -286,6 +287,7 @@ PYTESTS = \ reader8.py \ readernext.py \ walker.py \ + nsdel.py \ ctxterror.py\ readererr.py\ relaxng.py \ diff --git a/python/tests/nsdel.py b/python/tests/nsdel.py new file mode 100755 index 0000000..c06ded3 --- /dev/null +++ b/python/tests/nsdel.py @@ -0,0 +1,62 @@ +#!/usr/bin/python -u +# +# this test exercise the XPath basic engine, parser, etc, and +# allows to detect memory leaks +# +import sys +import libxml2 + +instance="""<?xml version="1.0"?> +<tag xmlns:foo='urn:foo' xmlns:bar='urn:bar' xmlns:baz='urn:baz' />""" + +def namespaceDefs(node): + n = node.nsDefs() + while n: + yield n + n = n.next + +def checkNamespaceDefs(node, count): + nsList = list(namespaceDefs(node)) + #print nsList + if len(nsList) != count : + raise Exception, "Error: saw %d namespace declarations. Expected %d" % (len(nsList), count) + +# Memory debug specific +libxml2.debugMemory(1) + +# Remove single namespace +doc = libxml2.parseDoc(instance) +node = doc.getRootElement() +checkNamespaceDefs(node, 3) +ns = node.removeNsDef('urn:bar') +checkNamespaceDefs(node, 2) +ns.freeNsList() +doc.freeDoc() + +# Remove all namespaces +doc = libxml2.parseDoc(instance) +node = doc.getRootElement() +checkNamespaceDefs(node, 3) +ns = node.removeNsDef(None) +checkNamespaceDefs(node, 0) +ns.freeNsList() +doc.freeDoc() + +# Remove a namespace refered to by a child +doc = libxml2.newDoc("1.0") +root = doc.newChild(None, "root", None) +namespace = root.newNs("http://example.com/sample", "s") +child = root.newChild(namespace, "child", None) +root.removeNsDef("http://example.com/sample") +doc.reconciliateNs(root) +namespace.freeNsList() +doc.serialize() # This should not segfault +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() |