dabo Commit
Revision 2170
Date: 2006-05-17 12:56:09 -0700 (Wed, 17 May 2006)
Author: paul

Changed:
U   trunk/dabo/lib/xmltodict.py

Log:
Added a test to xmltodict, which starts with a xmldict, calls dicttoxml, and
then calls xmltodict on that, to test the double-backslash thing.

The test fails, because we don't end up with a dict that matches the original
dict, because of the replacing of "\\" with "\\\\". If you comment line 168
and uncomment line 169, the test succeeds.

This leads me to believe that xmltodict is correct without the conversion (and
the fix for windows pathing should happen elsewhere), but I'm not sure yet
so for now at least we can play around with the test. No matter what we end
up with, ending up with an identical dict is a requirement! 


Diff:
Modified: trunk/dabo/lib/xmltodict.py
===================================================================
--- trunk/dabo/lib/xmltodict.py 2006-05-17 17:33:12 UTC (rev 2169)
+++ trunk/dabo/lib/xmltodict.py 2006-05-17 19:56:09 UTC (rev 2170)
@@ -166,6 +166,7 @@
                qt = '"'
        slsh = "\\"
        val = val.replace("<", "&lt;").replace(">", "&gt;").replace(slsh, 
slsh+slsh)
+#      val = val.replace("<", "&lt;").replace(">", "&gt;")
        if not noEscape:
                # First escape internal ampersands:
                val = val.replace("&", "&amp;")
@@ -255,3 +256,12 @@
                ret = header + ret
 
        return ret
+
+if __name__ == "__main__":
+       test_dict = {"name": "test", "attributes":{"path": "c:\\temp\\name"}}
+       print "test_dict:", test_dict
+       xml = dicttoxml(test_dict)
+       print "xml:", xml
+       test_dict2 = xmltodict(xml)
+       print "test_dict2:", test_dict2
+       print "same?:", test_dict == test_dict2




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to