[Zope-CVS] CVS: Packages/TestScripts - xml2dict.py:1.2

Chris Withers chrisw@nipltd.com
Thu, 7 Mar 2002 13:40:55 -0500


Update of /cvs-repository/Packages/TestScripts
In directory cvs.zope.org:/tmp/cvs-serv28815

Modified Files:
	xml2dict.py 
Log Message:
Added 'get' method to Node.

=== Packages/TestScripts/xml2dict.py 1.1 => 1.2 ===
         return value
 
+    def get(self,name,default=None):
+        return self.children.get(name,default)
+
     def __setitem__(self,name,value):
         dict = self.children
         cell = dict.get(name,())
@@ -163,8 +166,11 @@
         self.assertEqual(node['child1'],('child1',))
         node['child1']='child2'
         self.assertEqual(node['child1'],('child1','child2'))
+        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')
 
     def testSimple(self):
         """Test a simple one-level XML packet"""