[pypy-svn] r44054 - in pypy/branch/kill-ctypes/pypy/module/termios: . test

fijal at codespeak.net fijal at codespeak.net
Wed Jun 6 15:41:44 CEST 2007


Author: fijal
Date: Wed Jun  6 15:41:44 2007
New Revision: 44054

Modified:
   pypy/branch/kill-ctypes/pypy/module/termios/__init__.py
   pypy/branch/kill-ctypes/pypy/module/termios/test/test_termios.py
Log:
insanity-- kill some hacks regarding termios.error


Modified: pypy/branch/kill-ctypes/pypy/module/termios/__init__.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/module/termios/__init__.py	(original)
+++ pypy/branch/kill-ctypes/pypy/module/termios/__init__.py	Wed Jun  6 15:41:44 2007
@@ -1,7 +1,6 @@
 
 from pypy.interpreter.mixedmodule import MixedModule
 import termios
-from pypy.rpython.module.ll_termios import termios_error
 from pypy.rlib.nonconst import NonConstant
 
 class Module(MixedModule):
@@ -28,13 +27,6 @@
         'tcsetattr'   : 'interp_termios.tcsetattr',
     }
 
-    def startup(self, space):
-        # XXX nasty annotation trick
-        try:
-            raise termios_error(NonConstant(-3), NonConstant("xxx"))
-        except termios.error, e:
-            pass
-
 import termios
 from pypy.module.termios import interp_termios
 

Modified: pypy/branch/kill-ctypes/pypy/module/termios/test/test_termios.py
==============================================================================
--- pypy/branch/kill-ctypes/pypy/module/termios/test/test_termios.py	(original)
+++ pypy/branch/kill-ctypes/pypy/module/termios/test/test_termios.py	Wed Jun  6 15:41:44 2007
@@ -5,30 +5,30 @@
 from pypy.tool.autopath import pypydir
 from pypy.tool.udir import udir
 
-def setup_module(mod):
-    try:
-        import pexpect
-        mod.pexpect = pexpect
-    except ImportError:
-        py.test.skip("Pexpect not found")
-    try:
-        import termios
-        mod.termios = termios
-    except ImportError:
-        py.test.skip("termios not found")
-    py_py = py.path.local(pypydir).join('bin', 'py.py')
-    assert py_py.check()
-    mod.py_py = py_py
-
 class TestTermios(object):
+    def setup_class(cls):
+        try:
+            import pexpect
+        except ImportError:
+            py.test.skip("Pexpect not found")
+        try:
+            import termios
+        except ImportError:
+            py.test.skip("termios not found")
+        py_py = py.path.local(pypydir).join('bin', 'py.py')
+        assert py_py.check()
+        cls.py_py = py_py
+        cls.termios = termios
+        cls.pexpect = pexpect
+
     def _spawn(self, *args, **kwds):
         print 'SPAWN:', args, kwds
-        child = pexpect.spawn(*args, **kwds)
+        child = self.pexpect.spawn(*args, **kwds)
         child.logfile = sys.stdout
         return child
 
     def spawn(self, argv):
-        return self._spawn(sys.executable, [str(py_py)] + argv)
+        return self._spawn(sys.executable, [str(self.py_py)] + argv)
 
     def test_one(self):
         child = self.spawn(['--withmod-termios'])
@@ -71,10 +71,24 @@
         child = self.spawn(['--withmod-termios', str(f)])
         child.expect('ok!')
 
+    def test_ioctl_termios(self):
+        source = py.code.Source("""
+        import termios
+        import fcntl
+        lgt = len(fcntl.ioctl(2, termios.TIOCGWINSZ, '\000'*8))
+        assert lgt == 8
+        print 'ok!'
+        """)
+        f = udir.join("test_ioctl_termios.py")
+        f.write(source)
+        child = self.spawn(['--withmod-termios', '--withmod-fcntl', str(f)])
+        child.expect('ok!')
+
 class AppTestTermios(object):
     def setup_class(cls):
         cls.space = gettestobjspace(usemodules=['termios'])
         d = {}
+        import termios
         for name in dir(termios):
             val = getattr(termios, name)
             if name.isupper() and type(val) is int:



More information about the Pypy-commit mailing list