• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2import setup_test
3import libxml2
4import sys
5
6# Memory debug specific
7libxml2.debugMemory(1)
8
9dtd="""<!ELEMENT foo EMPTY>"""
10instance="""<?xml version="1.0"?>
11<foo></foo>"""
12
13dtd = libxml2.parseDTD(None, 'test.dtd')
14ctxt = libxml2.newValidCtxt()
15doc = libxml2.parseDoc(instance)
16ret = doc.validateDtd(ctxt, dtd)
17if ret != 1:
18    print("error doing DTD validation")
19    sys.exit(1)
20
21doc.freeDoc()
22dtd.freeDtd()
23del dtd
24del ctxt
25
26# Memory debug specific
27libxml2.cleanupParser()
28if libxml2.debugMemory(1) == 0:
29    print("OK")
30else:
31    print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
32
33