]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
tests: run test_gzip for curl_httpclient also 2679/head
authorPierce Lopez <pierce.lopez@gmail.com>
Fri, 14 Jun 2019 03:00:06 +0000 (23:00 -0400)
committerPierce Lopez <pierce.lopez@gmail.com>
Fri, 14 Jun 2019 03:00:06 +0000 (23:00 -0400)
move simple_httpclient test_gzip to the shared httpclient tests,
to test the decompress_response option for curl_httpclient as well

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

index 26a1ad7fc8a7eadb381f0c309ed82a68213f7bae..d1cc14673baafa3811ce4afbdb92a6afc1796f68 100644 (file)
@@ -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 = {}
index 956f7af3b1b6de79a180d1fdf90968310f6978ed..bb9ca119d8a7fb3956a5d8d7011159343c465553 100644 (file)
@@ -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)