MCPcopy Create free account
hub / github.com/StackStorm/st2 / test_try_loads

Method test_try_loads

st2common/tests/unit/test_jsonify.py:57–66  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

55 self.assertTrue(transformed_obj["yo"] == "bibimbao")
56
57 def test_try_loads(self):
58 # The function json.loads will fail and the function should return the original value.
59 values = ["abc", 123, True, object()]
60 for value in values:
61 self.assertEqual(jsonify.try_loads(value), value)
62
63 # The function json.loads succeed.
64 d = '{"a": 1, "b": true}'
65 expected = {"a": 1, "b": True}
66 self.assertDictEqual(jsonify.try_loads(d), expected)
67
68 def test_json_encode_decode_roundtrip_compatibility_between_different_libs(self):
69 class ObjectWithJsonMethod(object):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected