[pypy-svn] r31440 - in pypy/dist/pypy/module/posix: . test

rhymes at codespeak.net rhymes at codespeak.net
Mon Aug 21 15:27:34 CEST 2006


Author: rhymes
Date: Mon Aug 21 15:27:31 2006
New Revision: 31440

Modified:
   pypy/dist/pypy/module/posix/__init__.py
   pypy/dist/pypy/module/posix/interp_posix.py
   pypy/dist/pypy/module/posix/test/test_posix2.py
Log:
rollback to rev #31414 because the compilation breaks

Modified: pypy/dist/pypy/module/posix/__init__.py
==============================================================================
--- pypy/dist/pypy/module/posix/__init__.py	(original)
+++ pypy/dist/pypy/module/posix/__init__.py	Mon Aug 21 15:27:31 2006
@@ -10,33 +10,62 @@
 disguised Unix interface).  Refer to the library manual and
 corresponding Unix manual entries for more information on calls."""
 
+    applevel_name = os.name
+
     appleveldefs = {
-        'error': 'app_posix.error',
-        'stat_result': 'app_posix.stat_result',
-        'fdopen': 'app_posix.fdopen',
+    'error'      : 'app_posix.error',
+    'stat_result': 'app_posix.stat_result',
+    'fdopen'     : 'app_posix.fdopen',
     }
     
     interpleveldefs = {
-        'environ': 'interp_posix.get(space).w_environ'
+    'open'      : 'interp_posix.open',
+    'lseek'     : 'interp_posix.lseek',
+    'write'     : 'interp_posix.write',
+    'isatty'    : 'interp_posix.isatty',
+    'read'      : 'interp_posix.read',
+    'close'     : 'interp_posix.close',
+    'fstat'     : 'interp_posix.fstat',
+    'stat'      : 'interp_posix.stat',
+    'lstat'     : 'interp_posix.lstat',
+    'dup'       : 'interp_posix.dup',
+    'dup2'      : 'interp_posix.dup2',
+    'system'    : 'interp_posix.system',
+    'unlink'    : 'interp_posix.unlink',
+    'remove'    : 'interp_posix.remove',
+    'getcwd'    : 'interp_posix.getcwd',
+    'chdir'     : 'interp_posix.chdir',
+    'mkdir'     : 'interp_posix.mkdir',
+    'rmdir'     : 'interp_posix.rmdir',
+    'environ'   : 'interp_posix.get(space).w_environ',
+    'listdir'   : 'interp_posix.listdir',
+    'strerror'  : 'interp_posix.strerror',
+    'pipe'      : 'interp_posix.pipe',
+    'chmod'     : 'interp_posix.chmod',
+    'rename'    : 'interp_posix.rename',
+    '_exit'     : 'interp_posix._exit',
     }
-    
-    for func_name in ['ftruncate', 'putenv', 'unsetenv', 'getpid', 'link',
-        'symlink', 'readlink', 'fork', 'waitpid', 'chown', 'chroot',
-        'confstr', 'ctermid', 'fchdir', 'fpathconf', 'getegid', 'geteuid',
-        'getgid', 'getuid', 'getpgid', 'getpid', 'getppid', 'getpgrp',
-        'getsid', 'getlogin', 'getgroups', 'getloadavg', 'lchown', 'pathconf',
-        'minor', 'major', 'access', 'abort', '_exit', 'rename', 'chmod',
-        'pipe', 'strerror', 'listdir', 'rmdir', 'mkdir', 'chdir', 'getcwdu',
-        'getcwd', 'remove', 'unlink', 'system', 'dup2', 'dup', 'lstat',
-        'stat', 'fstat', 'close', 'read', 'write', 'isatty', 'lseek', 'open',
-        'sysconf', 'wait', 'uname', 'umask', 'ttyname']:
-        if hasattr(os, func_name):
-            interpleveldefs[func_name] = 'interp_posix.%s' % func_name
-    
+    if hasattr(os, 'ftruncate'):
+        interpleveldefs['ftruncate'] = 'interp_posix.ftruncate'
+    if hasattr(os, 'putenv'):
+        interpleveldefs['putenv'] = 'interp_posix.putenv'
+    if hasattr(posix, 'unsetenv'): # note: emulated in os
+        interpleveldefs['unsetenv'] = 'interp_posix.unsetenv'
+    if hasattr(os, 'getpid'):
+        interpleveldefs['getpid'] = 'interp_posix.getpid'
+    if hasattr(os, 'link'):
+        interpleveldefs['link'] = 'interp_posix.link'
+    if hasattr(os, 'symlink'):
+        interpleveldefs['symlink'] = 'interp_posix.symlink'
+    if hasattr(os, 'readlink'):
+        interpleveldefs['readlink'] = 'interp_posix.readlink'
+    if hasattr(os, 'fork'):
+        interpleveldefs['fork'] = 'interp_posix.fork'
+    if hasattr(os, 'waitpid'):
+        interpleveldefs['waitpid'] = 'interp_posix.waitpid'
+
+
 for constant in dir(os):
     value = getattr(os, constant)
     if constant.isupper() and type(value) is int:
         Module.interpleveldefs[constant] = "space.wrap(%s)" % value
-for const in ['confstr_names', 'pathconf_names', 'sysconf_names']:
-    if hasattr(os, const):
-        Module.interpleveldefs[const] = "space.wrap(%s)" % getattr(os, const)

Modified: pypy/dist/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/dist/pypy/module/posix/interp_posix.py	(original)
+++ pypy/dist/pypy/module/posix/interp_posix.py	Mon Aug 21 15:27:31 2006
@@ -1,4 +1,4 @@
-from pypy.interpreter.baseobjspace import ObjSpace, W_Root
+from pypy.interpreter.baseobjspace import ObjSpace
 from pypy.rpython.rarithmetic import intmask
 from pypy.rpython import ros
 from pypy.interpreter.error import OperationError
@@ -17,18 +17,6 @@
                                   space.wrap(errno),
                                   space.wrap(msg))
     return OperationError(space.w_OSError, w_error)
-
-def wrap_ioerror(space, e): 
-    assert isinstance(e, IOError) 
-    errno = e.errno
-    try:
-        msg = os.strerror(errno)
-    except ValueError:
-        msg = 'error %d' % errno
-    w_error = space.call_function(space.w_IOError,
-                                  space.wrap(errno),
-                                  space.wrap(msg))
-    return OperationError(space.w_IOError, w_error)
                           
 def open(space, fname, flag, mode=0777):
     """Open a file (for low level IO).
@@ -97,9 +85,7 @@
     try:
         os.ftruncate(fd, length)
     except OSError, e: 
-        raise wrap_oserror(space, e)
-    except IOError, e:
-        raise wrap_ioerror(space, e)
+        raise wrap_oserror(space, e) 
 ftruncate.unwrap_spec = [ObjSpace, int, int]
 
 def build_stat_result(space, st):
@@ -201,6 +187,7 @@
 remove.unwrap_spec = [ObjSpace, str]
 
 def getcwd(space):
+    """Return the current working directory."""
     try:
         cur = os.getcwd()
     except OSError, e: 
@@ -208,17 +195,6 @@
     else: 
         return space.wrap(cur)
 getcwd.unwrap_spec = [ObjSpace]
-getcwd.__doc__ = os.getcwd.__doc__
-
-def getcwdu(space):
-    try:
-        cur = os.getcwdu()
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    else:
-        return space.wrap(cur)
-getcwdu.unwrap_spec = [ObjSpace]
-getcwdu.__doc__ = os.getcwdu.__doc__
 
 def chdir(space, path):
     """Change the current working directory to the specified path."""
@@ -302,6 +278,7 @@
         del get(space).posix_putenv_garbage[name]
 unsetenv.unwrap_spec = [ObjSpace, str]
 
+
 def enumeratedir(space, dir):
     result = []
     while True:
@@ -393,276 +370,12 @@
 def fork(space):
     pid = os.fork()
     return space.wrap(pid)
-fork.unwrap_spec = [ObjSpace]
-fork.__doc__ = os.fork.__doc__
 
 def waitpid(space, pid, options):
     pid, status = os.waitpid(pid, options)
     return space.newtuple([space.wrap(pid), space.wrap(status)])
 waitpid.unwrap_spec = [ObjSpace, int, int]
-waitpid.__doc__ = os.waitpid.__doc__
-
-def wait(space):
-    pid, status = os.wait()
-    return space.newtuple([space.wrap(pid), space.wrap(status)])
-wait.unwrap_spec = [ObjSpace]
-wait.__doc__ = os.wait.__doc__
 
 def _exit(space, status):
     os._exit(status)
 _exit.unwrap_spec = [ObjSpace, int]
-_exit.__doc__ = os._exit.__doc__
-
-def abort(space):
-    os.abort()
-abort.unwrap_spec = [ObjSpace]
-abort.__doc__ = os.abort.__doc__
-
-def access(space, path, mode):
-    try:
-        res = os.access(path, mode)
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    return space.wrap(res)
-access.unwrap_spec = [ObjSpace, str, int]
-access.__doc__ = os.access.__doc__
-
-def chown(space, path, uid, gid):
-    try:
-        os.chown(path, uid, gid)
-    except OSError, e:
-        raise wrap_oserror(space, e)
-chown.unwrap_spec = [ObjSpace, str, int, int]
-chown.__doc__ = os.chown.__doc__
-
-def lchown(space, path, uid, gid):
-    try:
-        os.lchown(path, uid, gid)
-    except OSError, e:
-        raise wrap_oserror(space, e)
-lchown.unwrap_spec = [ObjSpace, str, int, int]
-lchown.__doc__ = os.lchown.__doc__
-
-def chroot(space, path):
-    try:
-        os.chroot(path)
-    except OSError, e:
-        raise wrap_oserror(space, e)
-chroot.unwrap_spec = [ObjSpace, str]
-chroot.__doc__ = os.chroot.__doc__
-
-def confstr(space, w_name):
-    w_name_type = space.type(w_name)
-    is_str = space.is_w(w_name_type, space.w_str)
-    is_int = space.is_w(w_name_type, space.w_int)
-
-    res = ''
-    try:
-        if is_str:
-            res = os.confstr(space.str_w(w_name))
-        elif is_int:
-            res = os.confstr(space.int_w(w_name))
-        else:
-            raise OperationError(space.w_TypeError,
-                space.wrap("configuration names must be strings or integers"))
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    except ValueError, e:
-        raise OperationError(space.w_ValueError,
-            space.wrap(e.args[0]))
-    else:
-        return space.wrap(res)
-confstr.unwrap_spec = [ObjSpace, W_Root]
-confstr.__doc__ = os.confstr.__doc__
-
-def ctermid(space):
-    return space.wrap(os.ctermid())
-ctermid.unwrap_spec = [ObjSpace]
-ctermid.__doc__ = os.ctermid.__doc__
-
-def fchdir(space, fd):
-    try:
-        os.fchdir(fd)
-    except OSError, e:
-        raise wrap_oserror(space, e)
-fchdir.unwrap_spec = [ObjSpace, int]
-fchdir.__doc__ = os.fchdir.__doc__
-
-def fpathconf(space, fd, w_name):
-    w_name_type = space.type(w_name)
-    is_str = space.is_w(w_name_type, space.w_str)
-    is_int = space.is_w(w_name_type, space.w_int)
-
-    res = ''
-    try:
-        if is_str:
-            res = os.fpathconf(fd, space.str_w(w_name))
-        elif is_int:
-            res = os.fpathconf(fd, space.int_w(w_name))
-        else:
-            raise OperationError(space.w_TypeError,
-                space.wrap("configuration names must be strings or integers"))
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    except ValueError, e:
-        raise OperationError(space.w_ValueError,
-            space.wrap(e.args[0]))
-    else:
-        return space.wrap(res)
-fpathconf.unwrap_spec = [ObjSpace, int, W_Root]
-fpathconf.__doc__ = os.fpathconf.__doc__
-
-def pathconf(space, path, w_name):
-    w_name_type = space.type(w_name)
-    is_str = space.is_w(w_name_type, space.w_str)
-    is_int = space.is_w(w_name_type, space.w_int)
-
-    res = ''
-    try:
-        if is_str:
-            res = os.pathconf(path, space.str_w(w_name))
-        elif is_int:
-            res = os.pathconf(path, space.int_w(w_name))
-        else:
-            raise OperationError(space.w_TypeError,
-                space.wrap("configuration names must be strings or integers"))
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    except ValueError, e:
-        raise OperationError(space.w_ValueError,
-            space.wrap(e.args[0]))
-    else:
-        return space.wrap(res)
-pathconf.unwrap_spec = [ObjSpace, str, W_Root]
-pathconf.__doc__ = os.pathconf.__doc__
-    
-def getegid(space):
-    return space.wrap(os.getegid())
-getegid.unwrap_spec = [ObjSpace]
-getegid.__doc__ = os.getegid.__doc__
-
-def geteuid(space):
-    return space.wrap(os.geteuid())
-geteuid.unwrap_spec = [ObjSpace]
-geteuid.__doc__ = os.geteuid.__doc__
-
-def getgid(space):
-    return space.wrap(os.getgid())
-getgid.unwrap_spec = [ObjSpace]
-getgid.__doc__ = os.getgid.__doc__
-
-def getuid(space):
-    return space.wrap(os.getuid())
-getuid.unwrap_spec = [ObjSpace]
-getuid.__doc__ = os.getuid.__doc__
-
-def getpgid(space, pid):
-    try:
-        res = os.getpgid(pid)
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    else:
-        return space.wrap(res)
-getpgid.unwrap_spec = [ObjSpace, int]
-getpgid.__doc__ = os.getpgid.__doc__
-
-def getpid(space):
-    return space.wrap(os.getpid())
-getpid.unwrap_spec = [ObjSpace]
-getpid.__doc__ = os.getpid.__doc__
-
-def getppid(space):
-    return space.wrap(os.getppid())
-getppid.unwrap_spec = [ObjSpace]
-getppid.__doc__ = os.getppid.__doc__
-
-def getpgrp(space):
-    return space.wrap(os.getpgrp())
-getpgrp.unwrap_spec = [ObjSpace]
-getpgrp.__doc__ = os.getpgrp.__doc__
-
-def getsid(space, pid):
-    try:
-        res = os.getsid(pid)
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    else:
-        return space.wrap(res)
-getsid.unwrap_spec = [ObjSpace, int]
-getsid.__doc__ = os.getsid.__doc__
-
-def getlogin(space):
-    return space.wrap(os.getlogin())
-getlogin.unwrap_spec = [ObjSpace]
-getlogin.__doc__ = os.getlogin.__doc__
-
-def getgroups(space):
-    return space.newlist(os.getgroups())
-getgroups.unwrap_spec = [ObjSpace]
-getgroups.__doc__ = os.getgroups.__doc__
-
-def getloadavg(space):
-    try:
-        res = os.getloadavg()
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    else:
-        return space.wrap(res)
-getloadavg.unwrap_spec = [ObjSpace]
-getloadavg.__doc__ = os.getloadavg.__doc__
-
-def major(space, device):
-    return space.wrap(os.major(device))
-major.unwrap_spec = [ObjSpace, int]
-major.__doc__ = os.major.__doc__
-
-def minor(space, device):
-    return space.wrap(os.minor(device))
-minor.unwrap_spec = [ObjSpace, int]
-minor.__doc__ = os.minor.__doc__
-
-def sysconf(space, w_name):
-    w_name_type = space.type(w_name)
-    is_str = space.is_w(w_name_type, space.w_str)
-    is_int = space.is_w(w_name_type, space.w_int)
-
-    res = ''
-    try:
-        if is_str:
-            res = os.sysconf(space.str_w(w_name))
-        elif is_int:
-            res = os.sysconf(space.int_w(w_name))
-        else:
-            raise OperationError(space.w_TypeError,
-                space.wrap("configuration names must be strings or integers"))
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    except ValueError, e:
-        raise OperationError(space.w_ValueError,
-            space.wrap(e.args[0]))
-    else:
-        return space.wrap(res)
-sysconf.unwrap_spec = [ObjSpace, W_Root]
-sysconf.__doc__ = os.sysconf.__doc__
-
-def uname(space):
-    name = os.uname()
-    name_w = [space.wrap(i) for i in name]
-    return space.newtuple(name_w)
-uname.unwrap_spec = [ObjSpace]
-uname.__doc__ == os.uname.__doc__
-
-def umask(space, mask):
-    return space.wrap(os.umask(mask))
-umask.unwrap_spec = [ObjSpace, int]
-umask.__doc__ == os.umask.__doc__
-
-def ttyname(space, fd):
-    try:
-        res = os.ttyname(fd)
-    except OSError, e:
-        raise wrap_oserror(space, e)
-    else:
-        return space.wrap(res)
-ttyname.unwrap_spec = [ObjSpace, int]
-ttyname.__doc__ = os.ttyname.__doc__

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	Mon Aug 21 15:27:31 2006
@@ -29,16 +29,13 @@
         fd = posix.open(path, posix.O_RDONLY, 0777)
         fd2 = posix.dup(fd)
         assert not posix.isatty(fd2) 
-        fd3 = 1
-        posix.dup2(fd2, fd3)
-        assert not posix.isatty(fd3)
         s = posix.read(fd, 1)
         assert s == 't'
         posix.lseek(fd, 5, 0)
         s = posix.read(fd, 1)
         assert s == 'i'
         stat = posix.fstat(fd) 
-        assert stat  # XXX
+        assert stat  # XXX 
         posix.close(fd2)
         posix.close(fd)
 
@@ -71,24 +68,8 @@
         #UMPF cpython raises IOError ex(self.posix.ftruncate, UNUSEDFD, 123)
         ex(self.posix.fstat, UNUSEDFD)
         ex(self.posix.stat, "qweqwehello")
-        ex(self.posix.lstat, "qweqwehello")
         # how can getcwd() raise? 
         ex(self.posix.dup, UNUSEDFD)
-        ex(self.posix.dup2, UNUSEDFD, UNUSEDFD)
-        ex(self.posix.unlink, str(UNUSEDFD))
-        ex(self.posix.remove, str(UNUSEDFD))
-        ex(self.posix.chdir, str(UNUSEDFD))
-        ex(self.posix.rmdir, str(UNUSEDFD))        
-        ex(self.posix.listdir, str(UNUSEDFD))        
-        ex(self.posix.chmod, str(UNUSEDFD), 0777)
-        ex(self.posix.chown, str(UNUSEDFD), -1, -1)
-        ex(self.posix.chroot, str(UNUSEDFD))
-        ex(self.posix.fchdir, UNUSEDFD)
-        ex(self.posix.getpgid, UNUSEDFD)
-        ex(self.posix.getsid, UNUSEDFD)
-        ex(self.posix.link, "foo", "foo")
-        ex(self.posix.readlink, "foo")
-        ex(self.posix.ttyname, UNUSEDFD)
 
     def test_fdopen(self):
         path = self.path 
@@ -114,9 +95,8 @@
         assert isinstance(self.posix.strerror(0), str)
         assert isinstance(self.posix.strerror(1), str)
 
-    def test_fork(self):
-        import os
-        if hasattr(__import__(os.name), "fork"):
+    if hasattr(__import__(os.name), "fork"):
+        def test_fork(self):
             os = self.posix
             pid = os.fork()
             if pid == 0:   # child
@@ -124,298 +104,16 @@
             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)
-    
-    def test_unlink(self):
-        import os
-        posix = self.posix
-        path = "foo"
-        fd = posix.open(path, posix.O_WRONLY | posix.O_CREAT)
-        assert os.path.exists(path)
-        try:
-            posix.unlink(path)
-        except OSError:
-            print "can't delete '%s'" % path
-        else:
-            assert not os.path.exists(path)
-        posix.close(fd)
-    test_remove = test_unlink
-    
-    def test_getcwd_chdir(self):
-        import os
-        posix = self.posix
-        path = os.path.split(posix.getcwd())[1]
-        posix.chdir('..')
-        posix.chdir(path)
-        posix.getcwd()
-        
-    def test_mkdir_rmdir(self):
-        import os
-        posix = self.posix
-        path = 'foo'
-        try:
-            posix.mkdir(path)
-        except OSError:
-            print "cannot create '%s' directory" % path
-        else:
-            assert os.path.exists(path)
-        try:
-            posix.rmdir(path)
-        except OSError:
-            print "cannot remove '%s' directory" % path
-        else:
-            assert not os.path.exists(path)
-    
-    def test_pipe(self):
-        posix = self.posix
-        r, w = posix.pipe()
-        data = 'foobar'
-        amount = posix.write(w, data)
-        posix.close(w)
-        read_data = posix.read(r, amount)
-        posix.close(r)
-        assert read_data == data
-    
-    def test_rename(self):
-        path = self.path
-        posix = self.posix
-        new_path = "foo"
-        posix.rename(path, new_path)
-        posix.rename(new_path, path)
-    
-    def test_ftruncate(self):
-        import os
-        if hasattr(__import__(os.name), "ftruncate"):
-            pdir = self.pdir
-            posix = self.posix
-            path = os.path.join(pdir, 'file1')
-            fd = posix.open(path, posix.O_WRONLY)
-            posix.ftruncate(fd, 2)
-            assert posix.stat(path)[6] == 2
-            posix.close(fd)
-            raises(IOError, posix.ftruncate, 123123, 1)
-        else:
-            skip("ftruncate not supported")
-    
-    def test_abort(self):
-        import os
-        if hasattr(__import__(os.name), "fork"):
-            posix = self.posix
-            pid = posix.fork()
-            if pid == 0:   # child
-                posix.abort()
-        else:
-            skip("can't test abort, because fork is missing")
-
-    def test_access(self):
-        posix = self.posix
-        assert posix.access('.', posix.W_OK)
-    
-    def test_chown(self):
-        import os
-        if hasattr(__import__(os.name), "chown"):
-            posix = self.posix
-            path = self.path
-            stat_info = posix.stat(path)
-            uid, gid = stat_info.st_uid, stat_info.st_gid
-            posix.chown(path, -1, -1)
-            posix.lchown(path, -1, -1)
-            stat_info = posix.stat(path)
-            assert uid == stat_info.st_uid
-            assert gid == stat_info.st_gid
-        else:
-            skip("chown not supported")
-        
-    def test_confstr(self):
-        import os
-        if hasattr(__import__(os.name), "confstr"):
-            posix = self.posix
-            assert isinstance(posix.confstr_names, dict)
-            name = posix.confstr_names.keys()[0]
-            assert isinstance(posix.confstr(name), str)
-            val = posix.confstr_names.values()[0]
-            assert isinstance(posix.confstr(val), str)
-            raises(ValueError, posix.confstr, 'xYz')
-            raises(TypeError, posix.confstr, None)
-            raises(TypeError, posix.confstr, dict())
-            assert isinstance(posix.confstr(12345), str)
-        else:
-            skip("confstr and confstr_names not supported")
-    
-    def test_ctermid(self):
-        import os
-        if hasattr(__import__(os.name), "ctermid"):
-            assert isinstance(self.posix.ctermid(), str)
-            
-    def test_fchdir(self):
-        import os
-        if hasattr(__import__(os.name), "fchdir"):
-            pdir = self.pdir
-            posix = self.posix
-            whereami = posix.getcwd()
-            fd = posix.open(pdir, posix.O_RDONLY)
-            posix.fchdir(fd)
-            posix.chdir(whereami)
-    
-    def test_fpathconf(self):
-        import os
-        if hasattr(__import__(os.name), "fpathconf"):
-            posix = self.posix
-            fd = posix.open(self.path, posix.O_RDONLY)
-            assert isinstance(posix.pathconf_names, dict)
-            name = posix.pathconf_names.keys()[-1]
-            assert isinstance(posix.fpathconf(fd, name), int)
-            val = posix.pathconf_names.values()[-1]
-            assert isinstance(posix.fpathconf(fd, val), int)
-            raises(ValueError, posix.fpathconf, fd, 'xYz')
-            raises(TypeError, posix.fpathconf, fd, None)
-            raises(TypeError, posix.fpathconf, fd, dict())
-        else:
-            skip("fpathconf and pathconf_names not supported")
-    
-    def test_pathconf(self):
-        import os
-        if hasattr(__import__(os.name), "pathconf"):
-            posix = self.posix
-            path = self.path
-            assert isinstance(posix.pathconf_names, dict)
-            name = posix.pathconf_names.keys()[-1]
-            assert isinstance(posix.pathconf(path, name), int)
-            val = posix.pathconf_names.values()[-1]
-            assert isinstance(posix.pathconf(path, val), int)
-            raises(ValueError, posix.pathconf, path, 'xYz')
-            raises(TypeError, posix.pathconf, path, None)
-            raises(TypeError, posix.pathconf, path, dict())
-        else:
-            skip("pathconf nad pathconf_names not supported")
-            
-    def test_getcwdu(self):
-        assert isinstance(self.posix.getcwdu(), unicode)
-    
-    def test_get_ids(self):
-        import os
-        if hasattr(__import__(os.name), "getegid"):
-            posix = self.posix
-            assert isinstance(posix.getegid(), int)
-            assert isinstance(posix.geteuid(), int)
-            assert isinstance(posix.getgid(), int)
-            assert isinstance(posix.getuid(), int)
-            assert posix.getpgid(0) == posix.getpgrp()
-            assert isinstance(posix.getpid(), int)
-            assert isinstance(posix.getppid(), int)
-            assert isinstance(posix.getsid(0), int)
-    
-    def test_getlogin(self):
-        import os
-        if hasattr(__import__(os.name), "getlogin"):
-            posix = self.posix
-            assert isinstance(posix.getlogin(), str)
-            # assert posix.getlogin() == pwd.getpwuid(os.getuid())[0]
-            
-    def test_getgroups(self):
-        import os
-        if hasattr(__import__(os.name), "getgroups"):
-            assert isinstance(self.posix.getgroups(), list)
-            
-    def test_getloadavg(self):
-        import os
-        if hasattr(__import__(os.name), "getloadavg"):
-            posix = self.posix
-            load = posix.getloadavg()
-            assert isinstance(load, tuple)
-            assert len(load) == 3
-            
-    def test_linking(self):
-        import os
-        if hasattr(__import__(os.name), "symlink"):
-            posix = self.posix
-            pdir = self.pdir
-            path = self.path
-            link = os.path.join(pdir, 'link')
-            posix.symlink(path, link)
-            hard_link = os.path.join(pdir, 'hard_link')
-            posix.link(path, hard_link)
-            assert posix.readlink(link) == path
-    
-    def test_major_minor(self):
-        posix = self.posix
-        fd = posix.open("/dev/urandom", posix.O_RDONLY)
-        assert isinstance(posix.major(fd), int)
-        assert isinstance(posix.minor(fd), int)
 
-    def test_sysconf(self):
-        import os
-        if hasattr(__import__(os.name), "sysconf"):
-            posix = self.posix
-            assert isinstance(posix.sysconf_names, dict)
-            name = posix.sysconf_names.keys()[0]
-            assert isinstance(posix.sysconf(name), int)
-            val = posix.sysconf_names.values()[0]
-            assert isinstance(posix.sysconf(val), int)
-            raises(ValueError, posix.sysconf, 'xYz')
-            raises(TypeError, posix.sysconf, None)
-            raises(TypeError, posix.sysconf, dict())
-        else:
-            skip("confstr and confstr_names not supported")
-            
-    def test_wait(self):
-        import os
-        if hasattr(__import__(os.name), "wait"):
-            posix = self.posix
-            pid = posix.fork()
-            if pid == 0:   # child
-                posix._exit(4)
-            pid1, status1 = os.wait()
-            assert pid1 == pid
-        else:
-            skip("wait not supported")
-            
-    def test_uname(self):
-        import os
-        if hasattr(__import__(os.name), "uname"):
-            uname = self.posix.uname()
-            assert isinstance(uname, tuple)
-            assert len(uname) == 5
-    
-    def test_umask(self):
-        import os
-        if hasattr(__import__(os.name), "umask"):
-            assert isinstance(self.posix.umask(022), int)
-            
-    def test_ttyname(self):
-        import os
-        if hasattr(__import__(os.name), "umask"):
-            assert isinstance(self.posix.ttyname(0), str)
-        
 class AppTestEnvironment(object):
     def setup_class(cls): 
         cls.space = space 
         cls.w_posix = space.appexec([], "(): import %s as m ; return m" % os.name)
         cls.w_os = space.appexec([], "(): import os; return os")
         cls.w_path = space.wrap(str(path))
-
     def test_environ(self):
         posix = self.posix
-        assert posix.environ['PATH']
-        del posix.environ['PATH']
-        def fn(): posix.environ['PATH']
-        raises(KeyError, fn)
+        os = self.os
 
     if hasattr(__import__(os.name), "unsetenv"):
         def test_unsetenv_nonexisting(self):



More information about the Pypy-commit mailing list