~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/http_server.py

Catch spurious exceptions (python-2.6) when SocketServer is shut down.

* bzrlib/tests/test_http.py:
(TestProxyHttpServer.proxied_in_env,
TestProxyHttpServer.not_proxied_in_env): Revert expected and
actual expressions to conform with bzr rules.

* bzrlib/tests/http_server.py:
(HttpServer.__repr__): Added for debug purposes.
(HttpServer._http_start): Catch spurious exceptions when running
with python-2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import posixpath
21
21
import random
22
22
import re
 
23
import select
23
24
import SimpleHTTPServer
24
25
import socket
25
26
import SocketServer
418
419
        # Allows tests to verify number of GET requests issued
419
420
        self.GET_request_nb = 0
420
421
 
 
422
    def __repr__(self):
 
423
        return "%s(%s:%s)" % \
 
424
            (self.__class__.__name__, self.host, self.port)
 
425
 
421
426
    def _get_httpd(self):
422
427
        if self._httpd is None:
423
428
            rhandler = self.request_handler
467
472
                httpd.handle_request()
468
473
            except socket.timeout:
469
474
                pass
 
475
            except (socket.error, select.error), e:
 
476
               if e[0] == errno.EBADF:
 
477
                   # Starting with python-2.6, handle_request may raise socket
 
478
                   # or select exceptions when the server is shut down (as we
 
479
                   # do).
 
480
                   pass
 
481
               else:
 
482
                   raise
470
483
 
471
484
    def _get_remote_url(self, path):
472
485
        path_parts = path.split(os.path.sep)