[pypy-commit] pypy popen-pclose: Add interpret-tests
krono
noreply at buildbot.pypy.org
Wed Mar 5 10:17:24 CET 2014
Author: Tobias Pape <tobias at netshed.de>
Branch: popen-pclose
Changeset: r69707:cf48985f2c5b
Date: 2014-03-03 20:00 +0100
http://bitbucket.org/pypy/pypy/changeset/cf48985f2c5b/
Log: Add interpret-tests
Also: adapt docstring as per fijal's request
diff --git a/rpython/rlib/rfile.py b/rpython/rlib/rfile.py
--- a/rpython/rlib/rfile.py
+++ b/rpython/rlib/rfile.py
@@ -116,11 +116,11 @@
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:
diff --git a/rpython/rlib/test/test_rfile.py b/rpython/rlib/test/test_rfile.py
--- a/rpython/rlib/test/test_rfile.py
+++ b/rpython/rlib/test/test_rfile.py
@@ -186,7 +186,7 @@
f.close()
-class TestPopen:
+class TestPopen(object):
def setup_class(cls):
if sys.platform == 'win32':
py.test.skip("not for win32")
@@ -207,3 +207,24 @@
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, [])
More information about the pypy-commit
mailing list