Commits

Amaury Forgeot d'Arc committed 39d9a53

A slighly better way to monkeypatch pyobject.from_ref()

  • Participants
  • Parent commits 5144606
  • Branches py3k

Comments (0)

Files changed (1)

File pypy/module/cpyext/test/test_ztranslation.py

 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')