Exemple #1
0
def test_reentrance():
    a = {'test_ints': 42, 'test_set': set([1, 2])}
    data = pickle(a)
    b = unpickle(data)
    assert a == b
    other_b = unpickle(data)
    assert a == other_b
    c = unpickle(data)
    assert a == c
def test_reentrance():
    a = {'test_ints': 42, 'test_set': set([1, 2])}
    data = pickle(a)
    b = unpickle(data)
    assert a == b
    other_b = unpickle(data)
    assert a == other_b
    c = unpickle(data)
    assert a == c
Exemple #3
0
 def get(self):
     with self._rlock:
         raw = self._reader.recv_bytes()
     if self._compress:
         data = zlib.decompress(raw)
     else:
         data = raw
     obj = unpickle(data)
     return obj
Exemple #4
0
 def get(self):
     with self._rlock:
         raw = self._reader.recv_bytes()
     if self._compress:
         data = zlib.decompress(raw)
     else:
         data = raw
     obj = unpickle(data)
     return obj
Exemple #5
0
def test_pickle_unpickle(obj, expected):
    data = pickle(obj)
    actual = unpickle(data)
    assert actual == expected

    with io.BytesIO() as buf:
        pickle_intob(obj, buf)
        size = buf.tell()
        buf.seek(0)
        actual = unpickle_fromb(buf, size)
    assert actual == expected
def test_pickle_unpickle(obj, expected):
    data = pickle(obj)
    actual = unpickle(data)
    assert actual == expected

    with io.BytesIO() as buf:
        pickle_intob(obj, buf)
        size = buf.tell()
        buf.seek(0)
        actual = unpickle_fromb(buf, size)
    assert actual == expected
def test_objects():
    f = Foo('foo')
    f.bars.append(Bar(1))
    f.bars.append(Bar(2))

    data = pickle(f)
    o = unpickle(data)

    assert type(o) == Foo
    assert o.name == 'foo'
    assert len(o.bars) == 2
    for i in range(2):
        assert f.bars[i].value == o.bars[i].value
Exemple #8
0
def test_objects():
    f = Foo('foo')
    f.bars.append(Bar(1))
    f.bars.append(Bar(2))

    data = pickle(f)
    o = unpickle(data)

    assert type(o) == Foo
    assert o.name == 'foo'
    assert len(o.bars) == 2
    for i in range(2):
        assert f.bars[i].value == o.bars[i].value
def test_pickle_unpickle(obj, expected):
    data = pickle(obj)
    actual = unpickle(data)
    assert actual == expected
Exemple #10
0
def test_pickle_unpickle(obj, expected):
    data = pickle(obj)
    actual = unpickle(data)
    assert actual == expected