diff options
author | Christopher Baines <mail@cbaines.net> | 2015-12-22 14:29:01 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2015-12-22 15:21:33 +0000 |
commit | 1b577142b7b3d006bfb3a3c0fc7ca900332c6523 (patch) | |
tree | 2eae884d18037e36856895e9fc1b1e95c87f6681 /debian/tests/single_request_py2 | |
parent | 1a6fe6bde5ecdf37b0278033772274dc503ec230 (diff) | |
download | python-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_py2')
-rwxr-xr-x | debian/tests/single_request_py2 | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/debian/tests/single_request_py2 b/debian/tests/single_request_py2 new file mode 100755 index 0000000..6f2b604 --- /dev/null +++ b/debian/tests/single_request_py2 @@ -0,0 +1,29 @@ +#!/usr/bin/python2.7 + +from multiprocessing import Process, Pipe +import BaseHTTPServer +import requests + +class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header("Content-type", 'text/plain') + self.end_headers() + self.wfile.write('test') + + def log_request(self, code='-', size='-'): + pass + +def start_server(pipe): + # start a simple server on any available port + httpd = BaseHTTPServer.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())) |