1. Stephen Tu
  2. mino-pypy

Source

mino-pypy / pypy / interpreter / test / test_main.py

Diff from to

File pypy/interpreter/test/test_main.py

 
 testresultoutput = '11\n'
 
-def checkoutput(space, expected_output,f,*args):
+
+def checkoutput(space, expected_output, f, *args):
     w_oldout = space.sys.get('stdout')
     capturefn = udir.join('capturefile')
-    capturefile = capturefn.open('w')
+    w_capturefile = space.call_method(space.builtin, "open", space.wrap(str(capturefn)), space.wrap("w"))
     w_sys = space.sys.getmodule('sys')
-    space.setattr(w_sys, space.wrap("stdout"), space.wrap(capturefile))
+    space.setattr(w_sys, space.wrap("stdout"), w_capturefile)
     try:
         f(*(args + (space,)))
     finally:
         space.setattr(w_sys, space.wrap("stdout"), w_oldout)
-    capturefile.close()
+    space.call_method(w_capturefile, "close")
     assert capturefn.read(mode='rU') == expected_output
 
 testfn = udir.join('tmp_hello_world.py')