File: test_memory.py

package info (click to toggle)
qm 1.1.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,628 kB
  • ctags: 10,249
  • sloc: python: 41,482; ansic: 20,611; xml: 12,837; sh: 485; makefile: 226
file content (50 lines) | stat: -rw-r--r-- 1,067 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50


import Cyclops,sys

from xml.dom.ext.reader import Sax2
from xml.dom import ext
def test():

    data = sys.stdin.read()

    doc = Sax2.FromXml(data)

    b1 = doc.createElementNS("http://foo.com","foo:branch")
    c1 = doc.createElementNS("http://foo.com","foo:child1")
    c2 = doc.createElementNS("http://foo.com","foo:child2")

    b1.setAttributeNS("http://foo.com","foo:a1","value-1")

    a1 = b1.getAttributeNodeNS("http://foo.com","a1")
    a1.value = "This shouldn't leak"
    
    b1.appendChild(c1)
    b1.appendChild(c2)
    
    doc.documentElement.appendChild(b1)
    
    r1 = doc.createElementNS("http://foo.com","foo:replace")
    doc.documentElement.replaceChild(r1,b1)

    b1.removeChild(c2)

    import cStringIO
    s = cStringIO.StringIO()
    import xml.dom.ext
    xml.dom.ext.Print(doc, stream = s)
    
    
    ext.ReleaseNode(doc)
    ext.ReleaseNode(b1)
    
    doc = Sax2.FromXml(data)
    ext.ReleaseNode(doc)



if __name__ == '__main__':
    cy = Cyclops.CycleFinder()
    cy.run(test)
    cy.find_cycles()
    cy.show_cycles()