Skip to content

Commit 461ee46

Browse files
committed
test: fix test for invalid etag in if-range.
The broken etag was missing the initial ", so the wrong code path was duplicated. Also add test that correct size of file was returned and fix comment(s).
1 parent 7ab7d19 commit 461ee46

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/test_liveserver.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def test_byte_Ranges(self):
240240
self.assertEqual(f.headers['content-range'],
241241
"bytes 10-20/%s"%expected_length)
242242

243-
# get all bytest starting from 11
243+
# get all bytes starting from 11
244244
hdrs = {"Range": "bytes=11-"}
245245
f = requests.get(self.url_base() + "/@@file/style.css", headers=hdrs)
246246
self.assertEqual(f.status_code, 206)
@@ -269,10 +269,11 @@ def test_byte_Ranges(self):
269269

270270
# range is too large, but etag is bad also, return whole file 200 code
271271
hdrs['Range'] = "0-99999" # too large
272-
hdrs['If-Range'] = etag[2:] # bad tag
272+
hdrs['If-Range'] = '"' + etag[2:] # start bad tag with "
273273
f = requests.get(self.url_base() + "/@@file/style.css", headers=hdrs)
274274
self.assertEqual(f.status_code, 200)
275-
# not checking content length since it could be compressed
275+
# note f.content has content-encoding (compression) undone.
276+
self.assertEqual(len(f.content), int(expected_length))
276277
self.assertNotIn('content-range', f.headers, 'content-range should not be present')
277278

278279
# range is too large, but etag is specified so return whole file

0 commit comments

Comments
 (0)