Пример #1
0
 def dump(self, object, name):
     '''
     dump(object, name)
     '''
     s = encode(object)
     if s:
         s = b64encode(s)
     self.redis.set(_resultname(name), s)
Пример #2
0
 def dump(self, object, name):
     '''
     dump(object, name)
     '''
     s = encode(object)
     if s:
         s = b64encode(s)
     self.redis.set(_resultname(name), s)
Пример #3
0
 def dump(self, obj, name):
     '''
     dump(object, name)
     '''
     s = encode(obj)
     sblob = self.bucket.blob(self.storage_key(name))
     sblob.upload_from_string(s, content_type=None)
     self.redis.set(self.redis_result_key(name), self.storage_key(name))
Пример #4
0
def test_decompress_stream_seek():
    s = encode(range(33))
    st = decompress_stream(StringIO(s))
    first = st.read(6)
    st.seek(-6, 1)
    second = st.read(6)
    assert first == second

    st = decompress_stream(StringIO(s))
    first = st.read(6)
    st.seek(-6, 1)
    second = st.read(8)
    assert first == second[:6]
Пример #5
0
def test_decompress_stream_seek():
    s = encode(list(range(33)))
    st = decompress_stream(BytesIO(s))
    first = st.read(6)
    st.seek(-6, 1)
    second = st.read(6)
    assert first == second

    st = decompress_stream(BytesIO(s))
    first = st.read(6)
    st.seek(-6, 1)
    second = st.read(8)
    assert first == second[:6]

    st = decompress_stream(BytesIO(s))
    st.seek(6, 1)
    st.seek(-6, 1)
    second = st.read(8)
    assert first == second[:6]
Пример #6
0
def test_encode():
    assert decode(encode(None)) is None
    assert decode(encode([])) == []
    assert decode(encode(list(range(33)))) == list(range(33))
Пример #7
0
def test_numpy_derived():
    a = Derived([1, 2, 3])
    assert type(decode(encode(a))) == type(a)
Пример #8
0
def test_numpy():
    assert np.all(decode(encode(np.arange(33))) == np.arange(33))
Пример #9
0
def test_encode():
    assert decode(encode(None)) is None
    assert decode(encode([])) == []
    assert decode(encode(range(33))) == range(33)
Пример #10
0
def test_numpy():
    assert np.all(decode(encode(np.arange(33))) == np.arange(33))
Пример #11
0
def test_numpy_derived():
    a = Derived([1,2,3])
    assert type(decode(encode(a))) == type(a)
Пример #12
0
def test_numpy():
    assert np.all(decode(encode(np.arange(33))) == np.arange(33))

    x = decode(encode({'res': np.arange(1024 * 1024)}))
    assert np.all(x['res'] == np.arange(1024 * 1024))
Пример #13
0
def test_encode():
    assert decode(encode(None)) is None
    assert decode(encode([])) == []
    assert decode(encode(range(33))) == range(33)
    assert np.all(decode(encode(np.arange(33))) == np.arange(33))