/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/test_test_server.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import errno
18
18
import socket
19
 
import SocketServer
 
19
try:
 
20
    import socketserver
 
21
except ImportError:
 
22
    import SocketServer as socketserver
20
23
import threading
21
24
 
22
25
 
23
 
from bzrlib import (
 
26
from breezy import (
24
27
    osutils,
25
28
    tests,
26
29
    )
27
 
from bzrlib.tests import test_server
28
 
from bzrlib.tests.scenarios import load_tests_apply_scenarios
 
30
from breezy.tests import test_server
 
31
from breezy.tests.scenarios import load_tests_apply_scenarios
29
32
 
30
33
 
31
34
load_tests = load_tests_apply_scenarios
62
65
            try:
63
66
                self.sock.shutdown(socket.SHUT_RDWR)
64
67
                self.sock.close()
65
 
            except socket.error, e:
 
68
            except socket.error as e:
66
69
                if e[0] in (errno.EBADF, errno.ENOTCONN):
67
70
                    # Right, the socket is already down
68
71
                    pass
77
80
        return self.sock.recv(bufsize)
78
81
 
79
82
 
80
 
class TCPConnectionHandler(SocketServer.BaseRequestHandler):
 
83
class TCPConnectionHandler(socketserver.BaseRequestHandler):
81
84
 
82
85
    def handle(self):
83
86
        self.done = False
188
191
        client.write('ping\n')
189
192
        try:
190
193
            self.assertEqual('', client.read())
191
 
        except socket.error, e:
 
194
        except socket.error as e:
192
195
            # On Windows, failing during 'handle' means we get
193
196
            # 'forced-close-of-connection'. Possibly because we haven't
194
197
            # processed the write request before we close the socket.