[Python-modules-team] Bug#796717: python-urllib3: simple autopkgtest to check requests.get

Edward Betts edward at 4angle.com
Sun Aug 23 16:15:11 UTC 2015


Package: python-urllib3
Version: 1.10.4-1
Severity: wishlist
Tags: patch

I've written a test that would catch Bug#796356 (python-urllib3 broken when
python-future is installed).

debian/tests/control:

  Tests: single_request
  Depends: python-future
  
debian/tests/single_request:

  #!/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()))
  
-- 
Edward.



More information about the Python-modules-team mailing list