[Zope-CVS] CVS: Packages/TestScripts - xml2dict.py:1.3
Chris Withers
chrisw@nipltd.com
Fri, 8 Mar 2002 02:50:16 -0500
Update of /cvs-repository/Packages/TestScripts
In directory cvs.zope.org:/tmp/cvs-serv27333
Modified Files:
xml2dict.py
Log Message:
Added 'items' method to node
=== Packages/TestScripts/xml2dict.py 1.2 => 1.3 ===
return self.children.get(name,default)
+ def items(self):
+ return self.children.items()
+
def __setitem__(self,name,value):
dict = self.children
cell = dict.get(name,())
@@ -163,14 +166,19 @@
node.addText(' finger')
self.assertEqual(node(),'fish finger')
node['child1']='child1'
+ self.assertEqual(node.items(),[('child1',('child1',))])
self.assertEqual(node['child1'],('child1',))
node['child1']='child2'
self.assertEqual(node['child1'],('child1','child2'))
+ self.assertEqual(node.items(),[('child1',('child1','child2'))])
+ node['child3']='child3'
+ self.assertEqual(node.items(),[('child1',('child1','child2'),),('child3',('child3',))])
self.assertEqual(node.get('child1'),('child1','child2'))
del node['child1']
self.assertRaises(KeyError,node.__getitem__,'child1')
self.assertEqual(node.get('child1'),None)
self.assertEqual(node.get('child1','fish'),'fish')
+ self.assertEqual(node.items(),[('child3',('child3',))])
def testSimple(self):
"""Test a simple one-level XML packet"""