summaryrefslogtreecommitdiff
path: root/python/tests
diff options
context:
space:
mode:
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/Makefile.am6
-rw-r--r--python/tests/Makefile.in6
-rwxr-xr-xpython/tests/dtdvalid.py32
-rw-r--r--python/tests/test.dtd1
4 files changed, 41 insertions, 4 deletions
diff --git a/python/tests/Makefile.am b/python/tests/Makefile.am
index 722e0ec..1ae9b6c 100644
--- a/python/tests/Makefile.am
+++ b/python/tests/Makefile.am
@@ -36,12 +36,14 @@ PYTESTS= \
thread2.py \
sync.py \
tstLastError.py \
- indexes.py
+ indexes.py \
+ dtdvalid.py
XMLS= \
tst.xml \
valid.xml \
- invalid.xml
+ invalid.xml \
+ test.dtd
EXTRA_DIST = $(PYTESTS) $(XMLS)
diff --git a/python/tests/Makefile.in b/python/tests/Makefile.in
index 3b55268..9113a20 100644
--- a/python/tests/Makefile.in
+++ b/python/tests/Makefile.in
@@ -285,12 +285,14 @@ PYTESTS = \
thread2.py \
sync.py \
tstLastError.py \
- indexes.py
+ indexes.py \
+ dtdvalid.py
XMLS = \
tst.xml \
valid.xml \
- invalid.xml
+ invalid.xml \
+ test.dtd
EXTRA_DIST = $(PYTESTS) $(XMLS)
all: all-am
diff --git a/python/tests/dtdvalid.py b/python/tests/dtdvalid.py
new file mode 100755
index 0000000..2011f2c
--- /dev/null
+++ b/python/tests/dtdvalid.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python -u
+import libxml2
+import sys
+
+# Memory debug specific
+libxml2.debugMemory(1)
+
+dtd="""<!ELEMENT foo EMPTY>"""
+instance="""<?xml version="1.0"?>
+<foo></foo>"""
+
+dtd = libxml2.parseDTD(None, 'test.dtd')
+ctxt = libxml2.newValidCtxt()
+doc = libxml2.parseDoc(instance)
+ret = doc.validateDtd(ctxt, dtd)
+if ret != 1:
+ print "error doing DTD validation"
+ sys.exit(1)
+
+doc.freeDoc()
+dtd.freeDtd()
+del dtd
+del ctxt
+
+# Memory debug specific
+libxml2.cleanupParser()
+if libxml2.debugMemory(1) == 0:
+ print "OK"
+else:
+ print "Memory leak %d bytes" % (libxml2.debugMemory(1))
+ libxml2.dumpMemory()
+
diff --git a/python/tests/test.dtd b/python/tests/test.dtd
new file mode 100644
index 0000000..b61b438
--- /dev/null
+++ b/python/tests/test.dtd
@@ -0,0 +1 @@
+<!ELEMENT foo EMPTY>