From 1b577142b7b3d006bfb3a3c0fc7ca900332c6523 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 22 Dec 2015 14:29:01 +0000 Subject: Add DEP8 tests This is a patch from Edward Betts (#796717). I then adjusted the test to work under python3 and added some additional packages to the Depends for the tests. --- debian/control | 1 + debian/tests/control | 7 +++++++ debian/tests/single_request_py2 | 29 +++++++++++++++++++++++++++++ debian/tests/single_request_py3 | 29 +++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 debian/tests/control create mode 100755 debian/tests/single_request_py2 create mode 100755 debian/tests/single_request_py3 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())) -- cgit v1.2.3