Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added minimal http client test

  • Loading branch information...
commit 50ee53ebfccf1b8022a8175c6d16dbaf4d7f98d1 1 parent d90e36c
@tailhook authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 tests/http.py
View
32 tests/http.py
@@ -0,0 +1,32 @@
+from .base import Test, interactive
+import time
+import http.server
+
+
+class RequestHandler(http.server.BaseHTTPRequestHandler):
+
+ def do_GET(self):
+ self.send_response(200)
+ self.send_header('Content-Length', '5')
+ self.end_headers()
+ self.wfile.write(b'HELLO')
+ self.wfile.flush()
+
+
+class Simple(Test):
+
+ def do_request(self):
+ self.z.sleep(0.1)
+ cli = self.z.http.HTTPClient('localhost', 9999)
+ self.assertEqual(cli.request('/').body, b'HELLO')
+
+ @interactive(do_request)
+ def test_req(self):
+ import zorro.http
+ srv = http.server.HTTPServer(('localhost', 9999), RequestHandler)
+ srv.handle_request()
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main()
Please sign in to comment.
Something went wrong with that request. Please try again.