def test_set_preferred_backend_allows_magic(self): """Tests that we can use the pluggable backends magically """ backend = 'os.path' jsonpickle.load_backend(backend, 'split', 'join', AttributeError) jsonpickle.set_preferred_backend(backend) slash_hello, world = jsonpickle.encode('/hello/world') jsonpickle.remove_backend(backend) self.assertEqual(slash_hello, '/hello') self.assertEqual(world, 'world')
def test_set_preferred_backend_allows_magic(self): """Tests that we can use the pluggable backends magically """ backend = "os.path" jsonpickle.load_backend(backend, "split", "join", AttributeError) jsonpickle.set_preferred_backend(backend) slash_hello, world = jsonpickle.encode("/hello/world") jsonpickle.remove_backend(backend) self.assertEqual(slash_hello, "/hello") self.assertEqual(world, "world")
import jsonpickle # pylint: disable=unused-variable, unused-argument jsonpickle.remove_backend("demjson") jsonpickle.set_preferred_backend("json") def dumps(obj, **args): return jsonpickle.encode(obj, unpicklable=False) def loads(json, **args): return jsonpickle.decode(json)