File: test_domimplementation.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 (58 lines) | stat: -rw-r--r-- 1,803 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
def test(tester):
    tester.startGroup('DOMImplementation')

    tester.startTest('Checking syntax')
    try:
        from xml.dom import DOMImplementation
        from xml.dom.DOMImplementation import DOMImplementation
    except:
        tester.error('Error in syntax', 1)
    tester.testDone()


    tester.startTest('Creating test environment')
    from xml.dom import implementation
    di = implementation
    tester.testDone()


    tester.startTest('Testing hasFeature()')
    if di.hasFeature('XML', '2.0') == 0:
        tester.error('hasFeature does not get feature with version');
    if di.hasFeature('XML', '') == 0:
        tester.error('hasFeature does not get feature (any version)');
    tester.testDone()


    tester.startTest('Testing createDocumentType()')
    dt = di.createDocumentType('NAME','PUBLICID','SYSTEMID')
    if dt.nodeName != 'NAME':
        tester.error('createDocumnent does not set qualifiedName properly')
    if dt.publicId != 'PUBLICID':
        tester.error('createDocumnent does not set namespaceURI properly')
    if dt.systemId != 'SYSTEMID':
        tester.error('createDocumnent does not set doctype properly')
    tester.testDone()


    tester.startTest('Testing createDocument()')
    doc = di.createDocument('','NAME',dt)
    if doc.namespaceURI != None:
        tester.error('createDocumnent does not set namespaceURI properly')
    if doc.documentElement.nodeName != 'NAME':
        tester.error('createDocumnent does not set qualifiedName properly')
    if doc.doctype != dt:
        tester.error('createDocumnent does not set doctype properly')
    tester.testDone()


    return tester.groupDone()


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

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