[CalendarServer-changes] [11423] CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/ python

source_changes at macosforge.org source_changes at macosforge.org
Wed Jun 26 01:17:13 PDT 2013


Revision: 11423
          http://trac.calendarserver.org//changeset/11423
Author:   glyph at apple.com
Date:     2013-06-26 01:17:13 -0700 (Wed, 26 Jun 2013)
Log Message:
-----------
Test for nested dictionaries.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py
    CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py

Modified: CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py
===================================================================
--- CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py	2013-06-26 08:16:54 UTC (rev 11422)
+++ CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/launchd.py	2013-06-26 08:17:13 UTC (rev 11423)
@@ -158,10 +158,13 @@
     """
     if isinstance(x, LaunchDictionary):
         result = {}
-        result.update(x)
+        for k, v in x.items():
+            result[k] = plainPython(v)
         return result
     elif isinstance(x, LaunchArray):
         result = []
+    else:
+        return x
 
 
 

Modified: CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py
===================================================================
--- CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py	2013-06-26 08:16:54 UTC (rev 11422)
+++ CalendarServer/branches/users/glyph/launchd-wrapper-bis/twext/python/test/test_launchd.py	2013-06-26 08:17:13 UTC (rev 11423)
@@ -110,6 +110,20 @@
                            plainPython(LaunchDictionary(self.testDict)))
 
 
+    def test_nestedLaunchDictionaryPlainPython(self):
+        """
+        L{plainPython} will convert a L{LaunchDictionary} containing another
+        L{LaunchDictionary} into a nested Python dictionary.
+        """
+        otherDict = lib.launch_data_alloc(lib.LAUNCH_DATA_DICTIONARY)
+        lib.launch_data_dict_insert(otherDict,
+                                    lib.launch_data_new_string("bar"), "foo")
+        lib.launch_data_dict_insert(self.testDict, otherDict, "delta")
+        self.assertEquals({b"alpha": b"alpha-value", b"beta": b"beta-value",
+                           b"gamma": 3, b"delta": {b"foo": b"bar"}},
+                           plainPython(LaunchDictionary(self.testDict)))
+
+
 class ArrayTests(TestCase):
     """
     Tests for L{LaunchArray}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130626/9e34687b/attachment.html>


More information about the calendarserver-changes mailing list