[pypy-svn] r28306 - pypy/dist/pypy/interpreter/test
pedronis at codespeak.net
pedronis at codespeak.net
Mon Jun 5 11:30:42 CEST 2006
Author: pedronis
Date: Mon Jun 5 11:30:41 2006
New Revision: 28306
Modified:
pypy/dist/pypy/interpreter/test/test_pickle.py
Log:
hide top frame helpers for test_pickle_frame
Modified: pypy/dist/pypy/interpreter/test/test_pickle.py
==============================================================================
--- pypy/dist/pypy/interpreter/test/test_pickle.py (original)
+++ pypy/dist/pypy/interpreter/test/test_pickle.py Mon Jun 5 11:30:41 2006
@@ -1,5 +1,44 @@
+def _attach_helpers(space):
+ def hide_top_frame(space, w_frame):
+ w_last = None
+ while w_frame.f_back:
+ w_last = w_frame
+ w_frame = w_frame.f_back
+ assert w_last
+ w_saved = w_last.f_back
+ w_last.f_back = None
+ return w_saved
+
+ def restore_top_frame(space, w_frame, w_saved):
+ while w_frame.f_back:
+ w_frame = w_frame.f_back
+ w_frame.f_back = w_saved
+
+ from pypy.interpreter import gateway
+
+ hide_gw = gateway.interp2app(hide_top_frame)
+ space.setitem(space.builtin.w_dict,
+ space.wrap('hide_top_frame'),
+ space.wrap(hide_gw))
+ restore_gw = gateway.interp2app(restore_top_frame)
+ space.setitem(space.builtin.w_dict,
+ space.wrap('restore_top_frame'),
+ space.wrap(restore_gw))
+
+def _detatch_helpers(space):
+ space.delitem(space.builtin.w_dict,
+ space.wrap('hide_top_frame'))
+ space.delitem(space.builtin.w_dict,
+ space.wrap('restore_top_frame'))
+
class AppTestInterpObjectPickling:
+ def setup_class(cls):
+ _attach_helpers(cls.space)
+
+ def teardown_class(cls):
+ _detatch_helpers(cls.space)
+
def test_pickle_code(self):
def f():
return 42
@@ -84,7 +123,9 @@
return tb.tb_frame
import pickle
f1 = f()
+ saved = hide_top_frame(f1)
pckl = pickle.dumps(f1)
+ restore_top_frame(f1, saved)
f2 = pickle.loads(pckl)
assert type(f1) is type(f2)
More information about the Pypy-commit
mailing list