Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #236 from tbetbetbe/development-test-bugfix
Browse files Browse the repository at this point in the history
Correct a test that fails sporadically
  • Loading branch information
Lukasa committed Apr 27, 2016
2 parents 065b539 + 7422011 commit 5704d26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions test/test_http11.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,15 +477,16 @@ def test_exception_raised_for_illegal_elements_in_iterable_body(self):
c = HTTP11Connection('httpbin.org')

rogue_element = 123
body = [b'legal1', b'legal2', rogue_element]
body_size = sum(len(bytes(x)) for x in body)
with pytest.raises(ValueError) as exc_info:
# content-length set so body type is set to BODY_FLAT. value
# doesn't matter
body = ['legal1', 'legal2', rogue_element]
c.request(
'GET',
'/get',
body=body,
headers={'content-length': str(len(map(str, body)))}
headers={'content-length': str(body_size)}
)
assert 'Elements in iterable body must be bytestrings. Illegal ' \
'element: {}'.format(rogue_element) \
Expand Down
15 changes: 10 additions & 5 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ def socket_handler(listener):
sock.send(f.serialize())

# Now, send a headers frame again, containing trailing headers.
f = build_headers_frame([(':res', 'no'), ('trailing', 'sure')], e)
f = build_headers_frame([
('trialing', 'no'),
('trailing', 'sure')], e)
f.flags.add('END_STREAM')
f.stream_id = 1
sock.send(f.serialize())
Expand All @@ -385,9 +387,10 @@ def socket_handler(listener):
# Confirm that we got the trailing headers, and that they don't contain
# reserved headers.
assert resp.trailers['trailing'] == [b'sure']
assert resp.trailers['trialing'] == [b'no']
assert resp.trailers.get(':res') is None
assert len(resp.headers) == 1
assert len(resp.trailers) == 1
assert len(resp.trailers) == 2

# Awesome, we're done now.
recv_event.wait(5)
Expand Down Expand Up @@ -429,7 +432,9 @@ def socket_handler(listener):
time.sleep(0.5)

# Now, send a headers frame again, containing trailing headers.
f = build_headers_frame([(':res', 'no'), ('trailing', 'sure')], e)
f = build_headers_frame([
('trialing', 'no'),
('trailing', 'sure')], e)
f.flags.add('END_STREAM')
f.stream_id = 1
sock.send(f.serialize())
Expand All @@ -453,9 +458,9 @@ def socket_handler(listener):
# reserved headers. More importantly, check the trailers *first*,
# before we read from the stream.
assert resp.trailers['trailing'] == [b'sure']
assert resp.trailers.get(':res') is None
assert resp.trailers['trialing'] == [b'no']
assert len(resp.headers) == 1
assert len(resp.trailers) == 1
assert len(resp.trailers) == 2

# Confirm that the stream is still readable.
assert resp.read() == b'have some data'
Expand Down

0 comments on commit 5704d26

Please sign in to comment.