From: Pierce Lopez Date: Fri, 14 Jun 2019 03:00:06 +0000 (-0400) Subject: tests: run test_gzip for curl_httpclient also X-Git-Tag: v6.1.0b1~71^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bd626bba5d4766dba171340dcd19998c4dd6773;p=thirdparty%2Ftornado.git tests: run test_gzip for curl_httpclient also move simple_httpclient test_gzip to the shared httpclient tests, to test the decompress_response option for curl_httpclient as well --- diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 26a1ad7fc..d1cc14673 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -3,6 +3,7 @@ import base64 import binascii from contextlib import closing import copy +import gzip import threading import datetime from io import BytesIO @@ -396,6 +397,23 @@ Transfer-Encoding: chunked self.assertEqual(type(response.code), int) self.assertEqual(type(response.effective_url), str) + def test_gzip(self): + # All the tests in this file should be using gzip, but this test + # ensures that it is in fact getting compressed, and also tests + # the httpclient's decompress=False option. + # Setting Accept-Encoding manually bypasses the client's + # decompression so we can see the raw data. + response = self.fetch( + "/chunk", decompress_response=False, headers={"Accept-Encoding": "gzip"} + ) + self.assertEqual(response.headers["Content-Encoding"], "gzip") + self.assertNotEqual(response.body, b"asdfqwer") + # Our test data gets bigger when gzipped. Oops. :) + # Chunked encoding bypasses the MIN_LENGTH check. + self.assertEqual(len(response.body), 34) + f = gzip.GzipFile(mode="r", fileobj=response.buffer) + self.assertEqual(f.read(), b"asdfqwer") + def test_header_callback(self): first_line = [] headers = {} diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 956f7af3b..bb9ca119d 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -1,7 +1,6 @@ import collections from contextlib import closing import errno -import gzip import logging import os import re @@ -226,22 +225,6 @@ class SimpleHTTPClientTestMixin(object): response = yield client.fetch(self.get_url("/countdown/3"), max_redirects=3) response.rethrow() - def test_gzip(self): - # All the tests in this file should be using gzip, but this test - # ensures that it is in fact getting compressed. - # Setting Accept-Encoding manually bypasses the client's - # decompression so we can see the raw data. - response = self.fetch( - "/chunk", use_gzip=False, headers={"Accept-Encoding": "gzip"} - ) - self.assertEqual(response.headers["Content-Encoding"], "gzip") - self.assertNotEqual(response.body, b"asdfqwer") - # Our test data gets bigger when gzipped. Oops. :) - # Chunked encoding bypasses the MIN_LENGTH check. - self.assertEqual(len(response.body), 34) - f = gzip.GzipFile(mode="r", fileobj=response.buffer) - self.assertEqual(f.read(), b"asdfqwer") - def test_max_redirects(self): response = self.fetch("/countdown/5", max_redirects=3) self.assertEqual(302, response.code)