]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Move redirect streaming callback test to simple_httpclient only. 1526/head
authorBen Darnell <ben@bendarnell.com>
Sun, 27 Sep 2015 19:08:40 +0000 (15:08 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 27 Sep 2015 19:52:16 +0000 (15:52 -0400)
This test passes with recent versions of libcurl but fails
with the version available on travis-ci.

tornado/test/httpclient_test.py
tornado/test/simple_httpclient_test.py

index fa69d81f6a6d2c590c79878f8bc3acaff0220eae..6254c266df55d09ba0f57de668c94ca2c2e5f398 100644 (file)
@@ -11,7 +11,7 @@ import threading
 import datetime
 from io import BytesIO
 
-from tornado.escape import utf8, to_unicode
+from tornado.escape import utf8
 from tornado import gen
 from tornado.httpclient import HTTPRequest, HTTPResponse, _RequestProxy, HTTPError, HTTPClient
 from tornado.httpserver import HTTPServer
@@ -480,21 +480,6 @@ Transfer-Encoding: chunked
         response.rethrow()
         self.assertEqual(response.body, b"Put body: hello")
 
-    def test_streaming_follow_redirects(self):
-        # When following redirects, header and streaming callbacks
-        # should only be called for the final result.
-        headers = []
-        chunks = []
-        self.fetch("/redirect?url=/hello",
-                   header_callback=headers.append,
-                   streaming_callback=chunks.append)
-        chunks = list(map(to_unicode, chunks))
-        self.assertEqual(chunks, ['Hello world!'])
-        # Make sure we only got one set of headers.
-        num_start_lines = len([h for h in headers if h.startswith("HTTP/")])
-        self.assertEqual(num_start_lines, 1)
-
-
 
 class RequestProxyTest(unittest.TestCase):
     def test_request_set(self):
index dc4c865bb9e033e8e79f58e117f56f7b74ef34c0..5214c1e45d3597626168404a0f9edc8bf303504a 100644 (file)
@@ -11,14 +11,15 @@ import socket
 import ssl
 import sys
 
+from tornado.escape import to_unicode
 from tornado import gen
 from tornado.httpclient import AsyncHTTPClient
 from tornado.httputil import HTTPHeaders, ResponseStartLine
 from tornado.ioloop import IOLoop
 from tornado.log import gen_log
 from tornado.netutil import Resolver, bind_sockets
-from tornado.simple_httpclient import SimpleAsyncHTTPClient, _default_ca_certs
-from tornado.test.httpclient_test import ChunkHandler, CountdownHandler, HelloWorldHandler
+from tornado.simple_httpclient import SimpleAsyncHTTPClient
+from tornado.test.httpclient_test import ChunkHandler, CountdownHandler, HelloWorldHandler, RedirectHandler
 from tornado.test import httpclient_test
 from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, ExpectLog
 from tornado.test.util import skipOnTravis, skipIfNoIPv6, refusing_port, unittest
@@ -145,6 +146,7 @@ class SimpleHTTPClientTestMixin(object):
             url("/no_content_length", NoContentLengthHandler),
             url("/echo_post", EchoPostHandler),
             url("/respond_in_prepare", RespondInPrepareHandler),
+            url("/redirect", RedirectHandler),
         ], gzip=True)
 
     def test_singleton(self):
@@ -416,6 +418,24 @@ class SimpleHTTPClientTestMixin(object):
                               expect_100_continue=True)
         self.assertEqual(response.code, 403)
 
+    def test_streaming_follow_redirects(self):
+        # When following redirects, header and streaming callbacks
+        # should only be called for the final result.
+        # TODO(bdarnell): this test belongs in httpclient_test instead of
+        # simple_httpclient_test, but it fails with the version of libcurl
+        # available on travis-ci. Move it when that has been upgraded
+        # or we have a better framework to skip tests based on curl version.
+        headers = []
+        chunks = []
+        self.fetch("/redirect?url=/hello",
+                   header_callback=headers.append,
+                   streaming_callback=chunks.append)
+        chunks = list(map(to_unicode, chunks))
+        self.assertEqual(chunks, ['Hello world!'])
+        # Make sure we only got one set of headers.
+        num_start_lines = len([h for h in headers if h.startswith("HTTP/")])
+        self.assertEqual(num_start_lines, 1)
+
 
 class SimpleHTTPClientTestCase(SimpleHTTPClientTestMixin, AsyncHTTPTestCase):
     def setUp(self):