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

Commit 9e8c5d4

Browse files
author
Tim Emiola
committed
Correct a test that fails sporadically
1 parent 065b539 commit 9e8c5d4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/test_http11.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,16 @@ def test_exception_raised_for_illegal_elements_in_iterable_body(self):
477477
c = HTTP11Connection('httpbin.org')
478478

479479
rogue_element = 123
480+
body = [b'legal1', b'legal2', rogue_element]
481+
body_size = sum(len(bytes(x)) for x in body)
480482
with pytest.raises(ValueError) as exc_info:
481483
# content-length set so body type is set to BODY_FLAT. value
482484
# doesn't matter
483-
body = ['legal1', 'legal2', rogue_element]
484485
c.request(
485486
'GET',
486487
'/get',
487488
body=body,
488-
headers={'content-length': str(len(map(str, body)))}
489+
headers={'content-length': str(body_size)}
489490
)
490491
assert 'Elements in iterable body must be bytestrings. Illegal ' \
491492
'element: {}'.format(rogue_element) \

0 commit comments

Comments
 (0)