]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Disable twisted_web tests on python 3.
authorBen Darnell <ben@bendarnell.com>
Sun, 1 Feb 2015 03:52:07 +0000 (22:52 -0500)
committerBen Darnell <ben@bendarnell.com>
Sun, 1 Feb 2015 03:52:07 +0000 (22:52 -0500)
The twisted.web modules are importable as of Twisted 15.0.0,
but appear to still have internal str/bytes issues.

tornado/test/runtests.py
tornado/test/twisted_test.py

index 8ab5f151a223104e39dd534c16c8c834d8b55f5b..acbb5695e2a11bdd90985c2acae82828f5104a1e 100644 (file)
@@ -112,6 +112,9 @@ def main():
     # instead of DeprecationWarnings.
     warnings.filterwarnings("ignore", category=PendingDeprecationWarning,
                             message="Please use assert.* instead")
+    # Twisted 15.0.0 triggers some warnings on py3 with -bb.
+    warnings.filterwarnings("ignore", category=BytesWarning,
+                            module=r"twisted\..*")
 
     logging.getLogger("tornado.access").setLevel(logging.CRITICAL)
 
index 732cb4cfaecf1adc4d3ee22edbca6b7306db1f68..b31ae94cb90e5e4f01be1a005291bac36adb5f53 100644 (file)
@@ -19,9 +19,11 @@ Unittest for the twisted-style reactor.
 
 from __future__ import absolute_import, division, print_function, with_statement
 
+import logging
 import os
 import shutil
 import signal
+import sys
 import tempfile
 import threading
 import warnings
@@ -44,7 +46,9 @@ try:
     from twisted.web.client import Agent, readBody
     from twisted.web.resource import Resource
     from twisted.web.server import Site
-    have_twisted_web = True
+    # As of Twisted 15.0.0, twisted.web is present but fails our
+    # tests due to internal str/bytes errors.
+    have_twisted_web = sys.version_info < (3,)
 except ImportError:
     have_twisted_web = False
 
@@ -53,6 +57,7 @@ try:
 except ImportError:
     import _thread as thread  # py3
 
+from tornado.escape import utf8
 from tornado import gen
 from tornado.httpclient import AsyncHTTPClient
 from tornado.httpserver import HTTPServer
@@ -411,7 +416,7 @@ class CompatibilityTests(unittest.TestCase):
         # http://twistedmatrix.com/documents/current/web/howto/client.html
         chunks = []
         client = Agent(self.reactor)
-        d = client.request('GET', url)
+        d = client.request(b'GET', utf8(url))
 
         class Accumulator(Protocol):
             def __init__(self, finished):
@@ -429,8 +434,17 @@ class CompatibilityTests(unittest.TestCase):
             return finished
         d.addCallback(callback)
 
-        def shutdown(ignored):
-            self.stop_loop()
+        def shutdown(failure):
+            if hasattr(self, 'stop_loop'):
+                self.stop_loop()
+            elif failure is not None:
+                # loop hasn't been initialized yet; try our best to
+                # get an error message out. (the runner() interaction
+                # should probably be refactored).
+                try:
+                    failure.raiseException()
+                except:
+                    logging.error('exception before starting loop', exc_info=True)
         d.addBoth(shutdown)
         runner()
         self.assertTrue(chunks)
@@ -444,7 +458,7 @@ class CompatibilityTests(unittest.TestCase):
             # by reading the body in one blob instead of streaming it with
             # a Protocol.
             client = Agent(self.reactor)
-            response = yield client.request('GET', url)
+            response = yield client.request(b'GET', utf8(url))
             with warnings.catch_warnings():
                 # readBody has a buggy DeprecationWarning in Twisted 15.0:
                 # https://twistedmatrix.com/trac/changeset/43379