mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix incorrect use of assertRaises
This commit is contained in:
parent
1e8c38d994
commit
e03e50730d
@ -125,13 +125,16 @@ class HTTPHeaderParser(object):
|
||||
val = existing + ', ' + val
|
||||
self.hdict[key] = val
|
||||
|
||||
if self.finished:
|
||||
raise ValueError('Header block already terminated')
|
||||
|
||||
if line == b'\r\n':
|
||||
# Normal end of headers
|
||||
commit()
|
||||
self.finished = True
|
||||
return
|
||||
|
||||
if line[0] in b' \t':
|
||||
if line and line[0] in b' \t':
|
||||
# It's a continuation line.
|
||||
if not self.lines:
|
||||
raise ValueError('Orphaned continuation line')
|
||||
|
@ -42,16 +42,16 @@ class TestHTTP(BaseTest):
|
||||
'accept-Encoding: two',
|
||||
'\r\n', accept_encoding='one, two')
|
||||
|
||||
def parse(line):
|
||||
HTTPHeaderParser()(line)
|
||||
def parse(*lines):
|
||||
lines = list(lines)
|
||||
lines.append(b'\r\n')
|
||||
self.assertRaises(ValueError, HTTPHeaderParser().push, *lines)
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
parse('Connection:mūs\r\n')
|
||||
parse('Connection\r\n')
|
||||
parse('Connection:a\r\n')
|
||||
parse('Connection:a\n')
|
||||
parse(' Connection:a\n')
|
||||
parse(':a\n')
|
||||
parse(b'Connection:mūs\r\n')
|
||||
parse(b'Connection\r\n')
|
||||
parse(b'Connection:a\r\n', b'\r\n')
|
||||
parse(b' Connection:a\n')
|
||||
parse(b':a\n')
|
||||
# }}}
|
||||
|
||||
def test_accept_encoding(self): # {{{
|
||||
|
Loading…
x
Reference in New Issue
Block a user