summaryrefslogtreecommitdiff
path: root/src/python/stdlib/json/tests/test_decode.py
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-10-26 13:50:50 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-26 13:50:50 (GMT)
commite46ef289e142982d7bd592faa7b0f85470364c01 (patch)
treecda253e03788f7db0a7cdcd05662f66b4455e298 /src/python/stdlib/json/tests/test_decode.py
parentd0d0d62bbcbb5c3417f8cba419c83bac192ea985 (diff)
downloadpowder-e46ef289e142982d7bd592faa7b0f85470364c01.zip
powder-e46ef289e142982d7bd592faa7b0f85470364c01.tar.gz
Remove Python console stuff
Diffstat (limited to 'src/python/stdlib/json/tests/test_decode.py')
-rw-r--r--src/python/stdlib/json/tests/test_decode.py41
1 files changed, 0 insertions, 41 deletions
diff --git a/src/python/stdlib/json/tests/test_decode.py b/src/python/stdlib/json/tests/test_decode.py
deleted file mode 100644
index 6afafe6..0000000
--- a/src/python/stdlib/json/tests/test_decode.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import decimal
-from unittest import TestCase
-from StringIO import StringIO
-
-import json
-from collections import OrderedDict
-
-class TestDecode(TestCase):
- def test_decimal(self):
- rval = json.loads('1.1', parse_float=decimal.Decimal)
- self.assertTrue(isinstance(rval, decimal.Decimal))
- self.assertEqual(rval, decimal.Decimal('1.1'))
-
- def test_float(self):
- rval = json.loads('1', parse_int=float)
- self.assertTrue(isinstance(rval, float))
- self.assertEqual(rval, 1.0)
-
- def test_decoder_optimizations(self):
- # Several optimizations were made that skip over calls to
- # the whitespace regex, so this test is designed to try and
- # exercise the uncommon cases. The array cases are already covered.
- rval = json.loads('{ "key" : "value" , "k":"v" }')
- self.assertEqual(rval, {"key":"value", "k":"v"})
-
- def test_object_pairs_hook(self):
- s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
- p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4),
- ("qrt", 5), ("pad", 6), ("hoy", 7)]
- self.assertEqual(json.loads(s), eval(s))
- self.assertEqual(json.loads(s, object_pairs_hook=lambda x: x), p)
- self.assertEqual(json.load(StringIO(s),
- object_pairs_hook=lambda x: x), p)
- od = json.loads(s, object_pairs_hook=OrderedDict)
- self.assertEqual(od, OrderedDict(p))
- self.assertEqual(type(od), OrderedDict)
- # the object_pairs_hook takes priority over the object_hook
- self.assertEqual(json.loads(s,
- object_pairs_hook=OrderedDict,
- object_hook=lambda x: None),
- OrderedDict(p))