File: test_collection.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 (48 lines) | stat: -rw-r--r-- 1,083 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
def error(msg):
	raise 'ERROR: ' + msg


def test():
	from xml.dom import implementation

	print 'testing source code syntax'
	from xml.dom.html.HTMLCollection import HTMLCollection

	print '### implementation: ' + str(implementation)
	doc = implementation.createHTMLDocument('Title')
	hc = doc._get_images()

	if hc.length != 0:
		error('Initial Length wrong');

	e = doc.createElement('IMG');
	doc.documentElement.appendChild(e);
	hc = doc._get_images()
	print 'test item'

	if hc[0].nodeName != e.nodeName:
		error('item returns the worng value');

	if hc.item(1) != None:
		error('item returns a value when it should be none')

	print 'item works'

	e.setAttribute('NAME','TEST')
	e.setAttribute('ID','1')
	print 'test namedItem'

	if hc.namedItem('TEST').nodeName != e.nodeName:
		error('namedItem did not find a named item')

	if hc.namedItem('1').nodeName != e.nodeName:
		error('namedItem did not find an IDed item')

	if hc.namedItem('TEST1') != None:
		error('namedItem found an item when one did not exist')

	print 'namedItem works';

if __name__ == '__main__':
	test()