Skip to content

Commit

Permalink
Add HTTP compression test for big files
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Quentel committed Jun 12, 2017
1 parent 128f6a6 commit 586b8c3
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Lib/test/test_httpservers.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ def setUp(self):
with open(path, 'wb') as temp:
temp.write(self.data)

# create big files, size > 2 << 18
self.repeat = (2 << 19) // len(self.data)
for ext in self.compressible_ext:
path = os.path.join(self.tempdir, 'test_big.{}'.format(ext))
with open(path, 'wb') as temp:
for _ in range(self.repeat):
temp.write(self.data)

def tearDown(self):
try:
os.chdir(self.cwd)
Expand Down Expand Up @@ -622,7 +630,14 @@ def test_header_set_supported_extension(self):
headers={'Accept-Encoding': 'gzip'})
self.assertTrue('Content-Encoding' in response.headers)
self.assertEqual(gzip.decompress(response.read()), self.data)


# same for big files
for ext in self.compressible_ext:
response = self.request(self.base_url + '/test_big.{}'.format(ext),
headers={'Accept-Encoding': 'gzip'})
self.assertTrue('Content-Encoding' in response.headers)
self.assertEqual(gzip.decompress(response.read()),
self.repeat * self.data)

cgi_file1 = """\
#!%s
Expand Down

0 comments on commit 586b8c3

Please sign in to comment.