def test_serialize_prvsnr_exception(): exc1 = ProvisionerError(123) exc2 = loads(dumps({'exc': exc1}))['exc'] assert type(exc1) is type(exc2) assert exc1.args == exc2.args
def test_serialize_builtins_exception(): exc1 = ValueError(123) exc2 = loads(dumps({'exc': exc1}))['exc'] assert type(exc1) is type(exc2) assert exc1.args == exc2.args
def test_special_values_serialization(): for value in values._values.values(): _json = dumps(value) value2 = loads(_json) assert value2 is value
def test_serialize_attr_cls(): obj1 = SomePrvsnrClass2(3, 4) obj1_json = dumps(obj1) obj2 = loads(obj1_json) assert obj1 == obj2
def test_serialize_simple(): obj1 = SomePrvsnrClass1(3, 4) obj1_json = dumps(obj1) obj2 = loads(obj1_json) assert obj1 == obj2
def value_to_str(v): if v is None: v = provisioner.NONE elif isinstance(v, (List, Dict)): v = serialize.dumps(v) return str(v)