diff options
author | Rune Halvorsen <runefh@gmail.com> | 2010-09-09 16:55:06 +0200 |
---|---|---|
committer | Rune Halvorsen <runefh@gmail.com> | 2010-09-09 16:55:06 +0200 |
commit | f7bdd5e9b5ebf1d3444bf4877308ba9e96f04556 (patch) | |
tree | 82ab5b3956a0506363d474a09dde7deb006a7161 | |
parent | c9f8a8249ad955e5ce24d554eb887a0fe1b6af81 (diff) | |
download | anyjson-f7bdd5e9b5ebf1d3444bf4877308ba9e96f04556.tar.gz |
Added dumps/loads as aliases for serializ/deserialize so it's in line with the stdlib json module
-rw-r--r-- | anyjson/__init__.py | 2 | ||||
-rw-r--r-- | tests/test_implementations.py | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/anyjson/__init__.py b/anyjson/__init__.py index 9e0295c..b1253b4 100644 --- a/anyjson/__init__.py +++ b/anyjson/__init__.py @@ -123,3 +123,5 @@ else: serialize = lambda value: implementation.serialize(value) deserialize = lambda value: implementation.deserialize(value) + dumps = serialize + loads = deserialize diff --git a/tests/test_implementations.py b/tests/test_implementations.py index e53e483..ceec00c 100644 --- a/tests/test_implementations.py +++ b/tests/test_implementations.py @@ -5,10 +5,12 @@ modnames = [e[0] for e in anyjson._modules] def test_default_serialization(): assert anyjson.serialize([1,2,3]).replace(" ", "") == "[1,2,3]" + assert anyjson.dumps([1,2,3]).replace(" ", "") == "[1,2,3]" def test_default_deserialization(): assert anyjson.deserialize("[1,2,3]") == [1,2,3] + assert anyjson.loads("[1,2,3]") == [1,2,3] def test_forced_serialization(): @@ -19,6 +21,7 @@ def test_forced_serialization(): continue # module can't be tested, try next assert anyjson.serialize([1,2,3]).replace(" ", "") == "[1,2,3]" + assert anyjson.dumps([1,2,3]).replace(" ", "") == "[1,2,3]" def test_forced_deserialization(): @@ -29,6 +32,7 @@ def test_forced_deserialization(): continue # module can't be tested, try next assert anyjson.deserialize("[1,2,3]") == [1,2,3] + assert anyjson.loads("[1,2,3]") == [1,2,3] def test_exceptions(): @@ -39,5 +43,7 @@ def test_exceptions(): continue # module can't be tested, try next assert_raises(TypeError, anyjson.serialize, [object()]) + assert_raises(TypeError, anyjson.dumps, [object()]) assert_raises(ValueError, anyjson.deserialize, "[") + assert_raises(ValueError, anyjson.loads, "[") |