Commits

Rune Halvorsen  committed d5c05cb

Added dumps/loads as aliases for serializ/deserialize so it's in line with the stdlib json module

  • Participants
  • Parent commits 1144f6a

Comments (0)

Files changed (2)

File anyjson/__init__.py

 
     serialize = lambda value: implementation.serialize(value)
     deserialize = lambda value: implementation.deserialize(value)
+    dumps = serialize
+    loads = deserialize

File tests/test_implementations.py

 
 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():
             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():
             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():
             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, "[")