summaryrefslogtreecommitdiff
path: root/Lib/test/test_httplib.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-04-13 14:57:44 +0000
committerJeremy Hylton <jeremy@alum.mit.edu>2001-04-13 14:57:44 +0000
commit208d6c395469d281f106e738489f5dce04166d2d (patch)
treeefbd14ae2f038841499a63366196475fce4b2e87 /Lib/test/test_httplib.py
parenta0e042b17c3bd3323fced74e04a1a884b4d416bd (diff)
downloadcpython-208d6c395469d281f106e738489f5dce04166d2d.tar.gz
Add test for SF bug #405427
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r--Lib/test/test_httplib.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
new file mode 100644
index 0000000000..aef65a6811
--- /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"