1. Tobias Pape
  2. pypy

Commits

Tobias Pape  committed cf48985

Add interpret-tests

Also: adapt docstring as per fijal's request

  • Participants
  • Parent commits 5840532
  • Branches popen-pclose

Comments (0)

Files changed (2)

File rpython/rlib/rfile.py

View file
  • Ignore whitespace
             rffi.free_nonmovingbuffer(value, ll_value)
 
     def close(self):
-        """ Closes the described file.
+        """Closes the described file.
 
-Attention! Unlike Python semantics, `close' does not return `None' upon
-success but `0', to be able to return an exit code for popen'ed files """
-
+        Attention! Unlike Python semantics, `close' does not return `None' upon
+        success but `0', to be able to return an exit code for popen'ed files
+        """
         ll_f = self.ll_file
         res = 0
         if ll_f:

File rpython/rlib/test/test_rfile.py

View file
  • Ignore whitespace
             f.close()
 
 
-class TestPopen:
+class TestPopen(object):
     def setup_class(cls):
         if sys.platform == 'win32':
             py.test.skip("not for win32")
         r = f.close()
         assert s == "%s\n" % printval
         assert r == retval
+
+class TestPopenR(BaseRtypingTest):
+    def setup_class(cls):
+        if sys.platform == 'win32':
+            py.test.skip("not for win32")
+
+    def test_popen(self):
+        def f():
+            f = rfile.create_popen_file("python -c 'print 42'", "r")
+            s = f.read()
+            f.close()
+        self.interpret(f, [])
+
+    def test_pclose(self):
+        retval = 32
+        cmd = "python -c 'import sys; print 45; sys.exit(%s)'" % retval
+        def f():
+            f = rfile.create_popen_file(cmd, "r")
+            s = f.read()
+            return f.close()
+        r = self.interpret(f, [])