aboutsummaryrefslogtreecommitdiff
path: root/debian/tests/single_request_py3
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2015-12-22 14:29:01 +0000
committerChristopher Baines <mail@cbaines.net>2015-12-22 15:21:33 +0000
commit1b577142b7b3d006bfb3a3c0fc7ca900332c6523 (patch)
tree2eae884d18037e36856895e9fc1b1e95c87f6681 /debian/tests/single_request_py3
parent1a6fe6bde5ecdf37b0278033772274dc503ec230 (diff)
downloadpython-urllib3-1b577142b7b3d006bfb3a3c0fc7ca900332c6523.tar
python-urllib3-1b577142b7b3d006bfb3a3c0fc7ca900332c6523.tar.gz
Add DEP8 tests
This is a patch from Edward Betts <edward@4angle.com> (#796717). I then adjusted the test to work under python3 and added some additional packages to the Depends for the tests.
Diffstat (limited to 'debian/tests/single_request_py3')
-rwxr-xr-xdebian/tests/single_request_py329
1 files changed, 29 insertions, 0 deletions
diff --git a/debian/tests/single_request_py3 b/debian/tests/single_request_py3
new file mode 100755
index 0000000..f15dbb5
--- /dev/null
+++ b/debian/tests/single_request_py3
@@ -0,0 +1,29 @@
+#!/usr/bin/python3
+
+from multiprocessing import Process, Pipe
+from http.server import HTTPServer, BaseHTTPRequestHandler
+import requests
+
+class RequestHandler(BaseHTTPRequestHandler):
+ def do_GET(self):
+ self.send_response(200)
+ self.send_header("Content-type", 'text/plain')
+ self.end_headers()
+ self.wfile.write(b'test')
+
+ def log_request(self, code='-', size='-'):
+ pass
+
+def start_server(pipe):
+ # start a simple server on any available port
+ httpd = HTTPServer(('', 0), RequestHandler)
+ pipe.send(httpd.socket.getsockname())
+ httpd.handle_request()
+
+if __name__ == '__main__':
+ parent, child = Pipe()
+ p = Process(target=start_server, args=(child,))
+ p.daemon = True
+ p.start()
+ # use the socket address from the test server
+ requests.get('http://{}:{}'.format(*parent.recv()))