mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fix for SF bug 661340: test_httplib fails on the mac.
The test no longer produces output with \r\n in it.
This commit is contained in:
parent
b1049e8eca
commit
ba60319a78
2 changed files with 65 additions and 41 deletions
|
@ -8,3 +8,4 @@ InvalidURL raised as expected
|
|||
reply: 'HTTP/1.1 200 OK\r\n'
|
||||
header: Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"
|
||||
header: Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"
|
||||
|
||||
|
|
|
@ -11,6 +11,27 @@ class FakeSocket:
|
|||
raise httplib.UnimplementedFileMode()
|
||||
return StringIO.StringIO(self.text)
|
||||
|
||||
# Collect output to a buffer so that we don't have to cope with line-ending
|
||||
# issues across platforms. Specifically, the headers will have \r\n pairs
|
||||
# and some platforms will strip them from the output file.
|
||||
|
||||
import sys
|
||||
|
||||
def test():
|
||||
buf = StringIO.StringIO()
|
||||
_stdout = sys.stdout
|
||||
try:
|
||||
sys.stdout = buf
|
||||
_test()
|
||||
finally:
|
||||
sys.stdout = _stdout
|
||||
|
||||
# print individual lines with endings stripped
|
||||
s = buf.getvalue()
|
||||
for line in s.split("\n"):
|
||||
print line.strip()
|
||||
|
||||
def _test():
|
||||
# Test HTTP status lines
|
||||
|
||||
body = "HTTP/1.1 200 Ok\r\n\r\nText"
|
||||
|
@ -56,3 +77,5 @@ r.begin()
|
|||
cookies = r.getheader("Set-Cookie")
|
||||
if cookies != hdr:
|
||||
raise AssertionError, "multiple headers not combined properly"
|
||||
|
||||
test()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue