diff options
-rw-r--r-- | debian/control | 1 | ||||
-rw-r--r-- | debian/tests/control | 7 | ||||
-rwxr-xr-x | debian/tests/single_request_py2 | 29 | ||||
-rwxr-xr-x | debian/tests/single_request_py3 | 29 |
4 files changed, 66 insertions, 0 deletions
diff --git a/debian/control b/debian/control index a57c01b..bd65874 100644 --- a/debian/control +++ b/debian/control @@ -27,6 +27,7 @@ X-Python3-Version: >= 3.0 Homepage: http://urllib3.readthedocs.org Vcs-Git: git://anonscm.debian.org/python-modules/packages/python-urllib3.git Vcs-Browser: https://anonscm.debian.org/cgit/python-modules/packages/python-urllib3.git +Testsuite: autopkgtest Package: python-urllib3 Architecture: all diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..fbf7a40 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,7 @@ +Tests: single_request_py2 +Restrictions: isolation-container +Depends: @, python-requests, python-future + +Tests: single_request_py3 +Restrictions: isolation-container +Depends: @, python3-requests, python3-future 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())) 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())) |