diff tests/test_fastpickle.py @ 989:8adc27285d93

bake: Big pass on bake performance. - Reduce the amount of data passed between processes. - Make inter-process data simple objects to make it easier to test with alternatives to pickle. - Make sources have the basic requirement to be able to find a content item from an item spec (path). - Make Hoedown the default Markdown formatter.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 19 Nov 2017 14:29:17 -0800
parents fcfbe103cfd1
children
line wrap: on
line diff
--- a/tests/test_fastpickle.py	Fri Nov 03 23:14:56 2017 -0700
+++ b/tests/test_fastpickle.py	Sun Nov 19 14:29:17 2017 -0800
@@ -1,6 +1,7 @@
+import io
 import datetime
 import pytest
-from piecrust.fastpickle import pickle, unpickle, pickle_obj, unpickle_obj
+from piecrust.fastpickle import pickle, unpickle, pickle_intob, unpickle_fromb
 
 
 class Foo(object):
@@ -36,6 +37,13 @@
     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')
@@ -54,11 +62,10 @@
 
 def test_reentrance():
     a = {'test_ints': 42, 'test_set': set([1, 2])}
-    data = pickle_obj(a)
-    b = unpickle_obj(data)
+    data = pickle(a)
+    b = unpickle(data)
     assert a == b
-    other_b = unpickle_obj(data)
+    other_b = unpickle(data)
     assert a == other_b
-    c = unpickle_obj(data)
+    c = unpickle(data)
     assert a == c
-