File: test_pythonic.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 (105 lines) | stat: -rw-r--r-- 2,601 bytes parent folder | download
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python

def test(tester):
    tester.startGroup('Python Representation')

    tester.startTest('Creating test environment')
    from xml.dom import implementation
    dt = implementation.createDocumentType('','','')
    doc = implementation.createDocument('','ROOT',dt)
    c = doc.createComment("Comment")
    tester.testDone()


    tester.startTest('Test Attribute')
    a = doc.createAttribute('ATTR_NAME')
    a.value = 'ATTR_VALUE'
    tester.message(str(a))
    tester.testDone()


    tester.startTest('Testing CDATASection')
    c1 = doc.createCDATASection('Short String')
    tester.message(str(c1))
    c2 = doc.createCDATASection('This is a much longer string, over 20 characters')
    tester.message(str(c2))
    tester.testDone()


    tester.startTest('Testing Comment')
    c1 = doc.createComment('Short Comment')
    tester.message(str(c1))
    c2 = doc.createComment('This is a much longer comment, over 20 characters')
    tester.message(str(c2))
    tester.testDone()


    tester.startTest('Testing Document')
    tester.message(str(doc))
    tester.testDone()


    tester.startTest('Testing Document Fragment')
    df = doc.createDocumentFragment()
    tester.message(str(df))
    tester.testDone()


    tester.startTest('Testing Element')
    e = doc.createElement('ELEMENT')
    tester.message(str(e))
    tester.testDone()


    tester.startTest('Testing Entity')
    e = doc._4dom_createEntity("ID1","ID2","NAME")
    tester.message(str(e))
    tester.testDone()


    tester.startTest('Testing Entity Reference')
    e = doc.createEntityReference('E-Ref')
    tester.message(str(e))
    tester.testDone()


    tester.startTest('Testing NamedNodeMap')
    nnm = implementation._4dom_createNamedNodeMap()
    tester.message(str(nnm))
    tester.testDone()


    tester.startTest('Testing NodeList')
    nl = implementation._4dom_createNodeList([e])
    tester.message(str(nl))
    tester.testDone()


    tester.startTest('Testing Notation')
    n = doc._4dom_createNotation("ID1","ID2","NAME")
    tester.message(str(n))
    tester.testDone()


    tester.startTest('Testing ProcessingInstruction')
    p = doc.createProcessingInstruction('This-is-a-long-target', 'short data')
    tester.message(str(p))
    tester.testDone()


    tester.startTest('Testing Text')
    t = doc.createTextNode('This is a very long text string')
    tester.message(str(t))
    tester.testDone()


    return tester.groupDone()


if __name__ == '__main__':
    import sys
    import TestSuite

    tester = TestSuite.TestSuite()
    retVal = test(tester)
    sys.exit(retVal)