File: test_memory.py

package info (click to toggle)
python-xml 0.8.4-10.1%2Blenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,972 kB
  • ctags: 10,628
  • sloc: python: 46,730; ansic: 14,354; xml: 968; makefile: 201; sh: 20
file content (48 lines) | stat: -rw-r--r-- 1,041 bytes parent folder | download | duplicates (3)
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
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()