Mercurial > piecrust2
comparison tests/test_fastpickle.py @ 717:fcfbe103cfd1
internal: Fix some bugs with the `fastpickle` module.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 28 May 2016 15:41:05 -0700 |
parents | 298f8f46432a |
children | 8adc27285d93 |
comparison
equal
deleted
inserted
replaced
716:42efc3634763 | 717:fcfbe103cfd1 |
---|---|
1 import datetime | 1 import datetime |
2 import pytest | 2 import pytest |
3 from piecrust.fastpickle import pickle, unpickle | 3 from piecrust.fastpickle import pickle, unpickle, pickle_obj, unpickle_obj |
4 | 4 |
5 | 5 |
6 class Foo(object): | 6 class Foo(object): |
7 def __init__(self, name): | 7 def __init__(self, name): |
8 self.name = name | 8 self.name = name |
49 assert o.name == 'foo' | 49 assert o.name == 'foo' |
50 assert len(o.bars) == 2 | 50 assert len(o.bars) == 2 |
51 for i in range(2): | 51 for i in range(2): |
52 assert f.bars[i].value == o.bars[i].value | 52 assert f.bars[i].value == o.bars[i].value |
53 | 53 |
54 | |
55 def test_reentrance(): | |
56 a = {'test_ints': 42, 'test_set': set([1, 2])} | |
57 data = pickle_obj(a) | |
58 b = unpickle_obj(data) | |
59 assert a == b | |
60 other_b = unpickle_obj(data) | |
61 assert a == other_b | |
62 c = unpickle_obj(data) | |
63 assert a == c | |
64 |