]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add option to disable the Resolver tests with an environment variable.
authorBen Darnell <ben@bendarnell.com>
Sat, 29 Mar 2014 14:03:15 +0000 (14:03 +0000)
committerBen Darnell <ben@bendarnell.com>
Sat, 29 Mar 2014 14:03:15 +0000 (14:03 +0000)
The resolver tests depend on external network resources; the twisted
resolver will time out when the network is unvailable instead of
returning an immediate failure like the other implementations.

tornado/test/netutil_test.py
tornado/test/util.py

index 89d782e6eeb7b75fbfa3e64b0ef765a26c16b579..bae9da3833a34bba719f6c8dbbfc1014fd7d88d2 100644 (file)
@@ -10,7 +10,7 @@ import time
 from tornado.netutil import BlockingResolver, ThreadedResolver, is_valid_ip, bind_sockets
 from tornado.stack_context import ExceptionStackContext
 from tornado.testing import AsyncTestCase, gen_test
-from tornado.test.util import unittest
+from tornado.test.util import unittest, skipIfNoNetwork
 
 try:
     from concurrent import futures
@@ -74,12 +74,14 @@ class _ResolverTestMixin(object):
                                         socket.AF_UNSPEC)
 
 
+@skipIfNoNetwork
 class BlockingResolverTest(AsyncTestCase, _ResolverTestMixin):
     def setUp(self):
         super(BlockingResolverTest, self).setUp()
         self.resolver = BlockingResolver(io_loop=self.io_loop)
 
 
+@skipIfNoNetwork
 @unittest.skipIf(futures is None, "futures module not present")
 class ThreadedResolverTest(AsyncTestCase, _ResolverTestMixin):
     def setUp(self):
@@ -91,6 +93,7 @@ class ThreadedResolverTest(AsyncTestCase, _ResolverTestMixin):
         super(ThreadedResolverTest, self).tearDown()
 
 
+@skipIfNoNetwork
 @unittest.skipIf(futures is None, "futures module not present")
 class ThreadedResolverImportTest(unittest.TestCase):
     def test_import(self):
@@ -116,6 +119,7 @@ class ThreadedResolverImportTest(unittest.TestCase):
         self.fail("import timed out")
 
 
+@skipIfNoNetwork
 @unittest.skipIf(pycares is None, "pycares module not present")
 class CaresResolverTest(AsyncTestCase, _ResolverTestMixin):
     def setUp(self):
@@ -123,6 +127,7 @@ class CaresResolverTest(AsyncTestCase, _ResolverTestMixin):
         self.resolver = CaresResolver(io_loop=self.io_loop)
 
 
+@skipIfNoNetwork
 @unittest.skipIf(twisted is None, "twisted module not present")
 @unittest.skipIf(getattr(twisted, '__version__', '0.0') < "12.1", "old version of twisted")
 class TwistedResolverTest(AsyncTestCase, _ResolverTestMixin):
index 36043104030b0b4cbe0fbd6b2846dd870e8e71fe..8db413788011a64a0ba72f3f39c015fcd8b0df5b 100644 (file)
@@ -17,3 +17,8 @@ skipIfNonUnix = unittest.skipIf(os.name != 'posix' or sys.platform == 'cygwin',
 # timing-related tests unreliable.
 skipOnTravis = unittest.skipIf('TRAVIS' in os.environ,
                                'timing tests unreliable on travis')
+
+# Set the environment variable NO_NETWORK=1 to disable any tests that
+# depend on an external network.
+skipIfNoNetwork = unittest.skipIf('NO_NETWORK' in os.environ,
+                                  'network access disabled')