[pypy-svn] r44588 - in pypy/dist/pypy/module/posix: . test
fijal at codespeak.net
fijal at codespeak.net
Thu Jun 28 10:53:13 CEST 2007
Author: fijal
Date: Thu Jun 28 10:53:12 2007
New Revision: 44588
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:
add os.ttyname
Modified: pypy/dist/pypy/module/posix/__init__.py
==============================================================================
--- pypy/dist/pypy/module/posix/__init__.py (original)
+++ pypy/dist/pypy/module/posix/__init__.py Thu Jun 28 10:53:12 2007
@@ -81,6 +81,8 @@
interpleveldefs['execve'] = 'interp_posix.execve'
#if hasattr(ctypes_posix, 'uname'):
# interpleveldefs['uname'] = 'interp_posix.uname'
+ if hasattr(os, 'ttyname'):
+ interpleveldefs['ttyname'] = 'interp_posix.ttyname'
def setup_after_space_initialization(self):
"""NOT_RPYTHON"""
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 Thu Jun 28 10:53:12 2007
@@ -501,3 +501,10 @@
def WIFSIGNALED(space, status):
return space.newbool(os.WIFSIGNALED(status))
WIFSIGNALED.unwrap_spec = [ObjSpace, int]
+
+def ttyname(space, fd):
+ try:
+ return space.wrap(os.ttyname(fd))
+ except OSError, e:
+ raise wrap_oserror(space, e)
+ttyname.unwrap_spec = [ObjSpace, int]
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 Thu Jun 28 10:53:12 2007
@@ -1,7 +1,10 @@
from pypy.objspace.std import StdObjSpace
from pypy.tool.udir import udir
from pypy.conftest import gettestobjspace
+from pypy.tool.autopath import pypydir
import os
+import py
+import sys
def setup_module(mod):
mod.space = gettestobjspace(usemodules=['posix'])
@@ -228,3 +231,33 @@
cmd = '''python -c "import os, sys; sys.exit(int('ABCABC' in os.environ))" '''
res = os.system(cmd)
assert res == 0
+
+class TestPexpect(object):
+ # XXX replace with AppExpectTest class as soon as possible
+ def setup_class(cls):
+ try:
+ import pexpect
+ except ImportError:
+ py.test.skip("pexpect not found")
+
+ def _spawn(self, *args, **kwds):
+ import pexpect
+ print 'SPAWN:', args, kwds
+ child = pexpect.spawn(*args, **kwds)
+ child.logfile = sys.stdout
+ return child
+
+ def spawn(self, argv):
+ py_py = py.path.local(pypydir).join('bin', 'py.py')
+ return self._spawn(sys.executable, [str(py_py)] + argv)
+
+ def test_ttyname(self):
+ source = py.code.Source("""
+ import os, sys
+ assert os.ttyname(sys.stdin.fileno())
+ print 'ok!'
+ """)
+ f = udir.join("test_ttyname.py")
+ f.write(source)
+ child = self.spawn([str(f)])
+ child.expect('ok!')
More information about the Pypy-commit
mailing list