Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r68411:39d9a53d774b
Date: 2013-12-12 23:48 +0100
http://bitbucket.org/pypy/pypy/changeset/39d9a53d774b/

Log:    A slighly better way to monkeypatch pyobject.from_ref()

diff --git a/pypy/module/cpyext/test/test_ztranslation.py 
b/pypy/module/cpyext/test/test_ztranslation.py
--- a/pypy/module/cpyext/test/test_ztranslation.py
+++ b/pypy/module/cpyext/test/test_ztranslation.py
@@ -1,13 +1,10 @@
 from pypy.objspace.fake.checkmodule import checkmodule
 from pypy.module.cpyext import pyobject
 
-def test_cpyext_translates():
+def test_cpyext_translates(monkeypatch):
     def from_ref(space, ref):
         # XXX: avoid 'assert isinstance(w_type, W_TypeObject)' from the
         # original from_ref, just return w_some_obj
         return space.w_object
-    old, pyobject.from_ref = pyobject.from_ref, from_ref
-    try:
-        checkmodule('cpyext', '_ffi')
-    finally:
-        pyobject.from_ref = old
+    monkeypatch.setattr(pyobject, 'from_ref', from_ref)
+    checkmodule('cpyext', '_ffi')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to