From: Ben Darnell Date: Mon, 17 Sep 2012 06:35:20 +0000 (-0700) Subject: Skip pipe and subprocess tests on windows. X-Git-Tag: v3.0.0~272^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca22303fba0b1e92c2f42cba702a0c56c4b4714d;p=thirdparty%2Ftornado.git Skip pipe and subprocess tests on windows. --- diff --git a/tornado/iostream.py b/tornado/iostream.py index 0ec3bd6f8..18b4460ac 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -43,6 +43,11 @@ try: except ImportError: ssl = None +try: + from tornado.platform.posix import _set_nonblocking +except ImportError: + _set_nonblocking = None + class BaseIOStream(object): """A utility class to write to and read from a non-blocking file or socket. @@ -804,7 +809,6 @@ class PipeIOStream(BaseIOStream): by `os.pipe`) rather than an open file object. """ def __init__(self, fd, *args, **kwargs): - from tornado.platform.posix import _set_nonblocking self.fd = fd _set_nonblocking(fd) super(PipeIOStream, self).__init__(*args, **kwargs) diff --git a/tornado/test/iostream_test.py b/tornado/test/iostream_test.py index 9f5b5cf09..119a4f6cd 100644 --- a/tornado/test/iostream_test.py +++ b/tornado/test/iostream_test.py @@ -4,7 +4,7 @@ from tornado.ioloop import IOLoop from tornado.iostream import IOStream, SSLIOStream, PipeIOStream from tornado.log import gen_log from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, bind_unused_port, ExpectLog -from tornado.test.util import unittest +from tornado.test.util import unittest, skipIfNonUnix from tornado.util import b from tornado.web import RequestHandler, Application import errno @@ -415,3 +415,4 @@ class TestPipeIOStream(AsyncTestCase): self.assertEqual(data, b("ld")) rs.close() +TestPipeIOStream = skipIfNonUnix(TestPipeIOStream) diff --git a/tornado/test/process_test.py b/tornado/test/process_test.py index 950aa8d45..7bd750340 100644 --- a/tornado/test/process_test.py +++ b/tornado/test/process_test.py @@ -14,7 +14,7 @@ from tornado.log import gen_log from tornado.process import fork_processes, task_id, Subprocess from tornado.simple_httpclient import SimpleAsyncHTTPClient from tornado.testing import bind_unused_port, ExpectLog, AsyncTestCase -from tornado.test.util import unittest +from tornado.test.util import unittest, skipIfNonUnix from tornado.util import b from tornado.web import RequestHandler, Application @@ -120,8 +120,7 @@ class ProcessTest(unittest.TestCase): except Exception: logging.error("exception in child process %d", id, exc_info=True) raise -ProcessTest = unittest.skipIf(os.name != 'posix' or sys.platform == 'cygwin', - "non-unix platform")(ProcessTest) +ProcessTest = skipIfNonUnix(ProcessTest) class SubprocessTest(AsyncTestCase): @@ -167,3 +166,4 @@ class SubprocessTest(AsyncTestCase): self.assertEqual(subproc.returncode, ret) self.assertTrue(os.WIFSIGNALED(ret)) self.assertEqual(os.WTERMSIG(ret), signal.SIGTERM) +SubprocessTest = skipIfNonUnix(SubprocessTest) diff --git a/tornado/test/util.py b/tornado/test/util.py index 26d843d5b..b048b5027 100644 --- a/tornado/test/util.py +++ b/tornado/test/util.py @@ -1,5 +1,6 @@ from __future__ import absolute_import, division, with_statement +import os import sys # Encapsulate the choice of unittest or unittest2 here. @@ -8,3 +9,6 @@ if sys.version_info >= (2, 7): import unittest else: import unittest2 as unittest + +skipIfNonUnix = unittest.skipIf(os.name != 'posix' or sys.platform == 'cygwin', + "non-unix platform")