VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/python/tests/tstmem.py@ 108403

最後變更 在這個檔案從108403是 105420,由 vboxsync 提交於 8 月 前

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:executable 設為 *
檔案大小: 792 位元組
 
1#!/usr/bin/env python3
2import setup_test
3import libxml2
4
5try:
6 import libxml2mod
7except ModuleNotFoundError:
8 from libxmlmods import libxml2mod
9
10import sys
11
12def error(msg, data):
13 pass
14
15# Memory debug specific
16libxml2.debugMemory(1)
17
18dtd="""<!ELEMENT foo EMPTY>"""
19instance="""<?xml version="1.0"?>
20<foo></foo>"""
21
22dtd = libxml2.parseDTD(None, 'test.dtd')
23ctxt = libxml2.newValidCtxt()
24libxml2mod.xmlSetValidErrors(ctxt._o, error, error)
25doc = libxml2.parseDoc(instance)
26ret = doc.validateDtd(ctxt, dtd)
27if ret != 1:
28 print("error doing DTD validation")
29 sys.exit(1)
30
31doc.freeDoc()
32dtd.freeDtd()
33del dtd
34del ctxt
35
36# Memory debug specific
37libxml2.cleanupParser()
38if libxml2.debugMemory(1) == 0:
39 print("OK")
40else:
41 print("Memory leak %d bytes" % (libxml2.debugMemory(1)))
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette