]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.10/Lib/json/tests/test_separators.py
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 4/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Lib / json / tests / test_separators.py
diff --git a/AppPkg/Applications/Python/Python-2.7.10/Lib/json/tests/test_separators.py b/AppPkg/Applications/Python/Python-2.7.10/Lib/json/tests/test_separators.py
new file mode 100644 (file)
index 0000000..b468c3b
--- /dev/null
@@ -0,0 +1,44 @@
+import textwrap\r
+from json.tests import PyTest, CTest\r
+\r
+\r
+class TestSeparators(object):\r
+    def test_separators(self):\r
+        h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',\r
+             {'nifty': 87}, {'field': 'yes', 'morefield': False} ]\r
+\r
+        expect = textwrap.dedent("""\\r
+        [\r
+          [\r
+            "blorpie"\r
+          ] ,\r
+          [\r
+            "whoops"\r
+          ] ,\r
+          [] ,\r
+          "d-shtaeou" ,\r
+          "d-nthiouh" ,\r
+          "i-vhbjkhnth" ,\r
+          {\r
+            "nifty" : 87\r
+          } ,\r
+          {\r
+            "field" : "yes" ,\r
+            "morefield" : false\r
+          }\r
+        ]""")\r
+\r
+\r
+        d1 = self.dumps(h)\r
+        d2 = self.dumps(h, indent=2, sort_keys=True, separators=(' ,', ' : '))\r
+\r
+        h1 = self.loads(d1)\r
+        h2 = self.loads(d2)\r
+\r
+        self.assertEqual(h1, h)\r
+        self.assertEqual(h2, h)\r
+        self.assertEqual(d2, expect)\r
+\r
+\r
+class TestPySeparators(TestSeparators, PyTest): pass\r
+class TestCSeparators(TestSeparators, CTest): pass\r