From: Ben Darnell Date: Sun, 27 Sep 2015 19:08:40 +0000 (-0400) Subject: Move redirect streaming callback test to simple_httpclient only. X-Git-Tag: v4.3.0b1~25^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=852c209821eacbcb45b9b3b1862ab73a0f103cfe;p=thirdparty%2Ftornado.git Move redirect streaming callback test to simple_httpclient only. This test passes with recent versions of libcurl but fails with the version available on travis-ci. --- diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index fa69d81f6..6254c266d 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -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): diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index dc4c865bb..5214c1e45 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -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):