[pypy-svn] r31415 - pypy/dist/pypy/module/posix/test

rhymes at codespeak.net rhymes at codespeak.net
Sun Aug 20 18:09:14 CEST 2006


Author: rhymes
Date: Sun Aug 20 18:09:12 2006
New Revision: 31415

Modified:
   pypy/dist/pypy/module/posix/test/test_posix2.py
Log:
more tests and fix test_fork

Modified: pypy/dist/pypy/module/posix/test/test_posix2.py
==============================================================================
--- pypy/dist/pypy/module/posix/test/test_posix2.py	(original)
+++ pypy/dist/pypy/module/posix/test/test_posix2.py	Sun Aug 20 18:09:12 2006
@@ -95,8 +95,9 @@
         assert isinstance(self.posix.strerror(0), str)
         assert isinstance(self.posix.strerror(1), str)
 
-    if hasattr(__import__(os.name), "fork"):
-        def test_fork(self):
+    def test_fork(self):
+        import os
+        if hasattr(__import__(os.name), "fork"):
             os = self.posix
             pid = os.fork()
             if pid == 0:   # child
@@ -104,6 +105,23 @@
             pid1, status1 = os.waitpid(pid, 0)
             assert pid1 == pid
             # XXX check status1
+        else:
+            skip("fork not supported")
+
+    def test_read_write(self):
+        path = self.path
+        posix = self.posix
+        fd = posix.open(path, posix.O_WRONLY)
+        posix.write(fd, "\nfoo")
+        posix.close(fd)
+        fd = posix.open(path, posix.O_RDONLY)
+        raises(OSError, posix.write, fd, "foo")
+        buf = []
+        buf.append(posix.read(fd, 4))
+        assert len(buf[0]) == 4
+        buf.append(posix.read(fd, 255))
+        assert "".join(buf) == "\nfoo is a test"
+        posix.close(fd)
 
 class AppTestEnvironment(object):
     def setup_class(cls): 



More information about the Pypy-commit mailing list