summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-04-13 14:57:44 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-04-13 14:57:44 (GMT)
commit79fa2b6073b67ae0351cad5b792f2be815e60c68 (patch)
tree87d3b3da294fd95ef26bf3eeb52e022f6e4239f1 /Lib
parent23d40477909054d8c0e7459601093ba750b4ea8b (diff)
downloadcpython-79fa2b6073b67ae0351cad5b792f2be815e60c68.zip
cpython-79fa2b6073b67ae0351cad5b792f2be815e60c68.tar.gz
cpython-79fa2b6073b67ae0351cad5b792f2be815e60c68.tar.bz2
Add test for SF bug #405427
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/output/test_httplib5
-rw-r--r--Lib/test/test_httplib.py31
2 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/output/test_httplib b/Lib/test/output/test_httplib
new file mode 100644
index 0000000..ed235c2
--- /dev/null
+++ b/Lib/test/output/test_httplib
@@ -0,0 +1,5 @@
+test_httplib
+reply: 'HTTP/1.1 200 Ok\r\n'
+Text
+reply: 'HTTP/1.1 400.100 Not Ok\r\n'
+BadStatusLine raised as expected
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
new file mode 100644
index 0000000..aef65a6
--- /dev/null
+++ b/Lib/test/test_httplib.py
@@ -0,0 +1,31 @@
+from test.test_support import verify,verbose
+import httplib
+import StringIO
+
+class FakeSocket:
+ def __init__(self, text):
+ self.text = text
+
+ def makefile(self, mode, bufsize=None):
+ if mode != 'r' and mode != 'rb':
+ raise UnimplementedFileMode()
+ return StringIO.StringIO(self.text)
+
+# Test HTTP status lines
+
+body = "HTTP/1.1 200 Ok\r\n\r\nText"
+sock = FakeSocket(body)
+resp = httplib.HTTPResponse(sock,1)
+resp.begin()
+print resp.read()
+resp.close()
+
+body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
+sock = FakeSocket(body)
+resp = httplib.HTTPResponse(sock,1)
+try:
+ resp.begin()
+except httplib.BadStatusLine:
+ print "BadStatusLine raised as expected"
+else:
+ print "Expect BadStatusLine"