def test_binary(): ejson_obj = ejson.new_binary(5) assert isinstance(ejson_obj, bytearray) assert len(ejson_obj) == 5 ejson_obj[:] = b'sure.' json_obj = {'$binary': "c3VyZS4="} json_str = '{"$binary": "c3VyZS4="}' _assert_serialize_deserialize_equals_and_is_binary( ejson_obj, json_obj, json_str, True)
def test_is_binary(): assert ejson.is_binary(ejson.new_binary(1)) assert not ejson.is_binary('foo')
def test_new_binary(): obj = ejson.new_binary(8) assert isinstance(obj, bytearray) assert 8 == len(obj)