~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

(jameinel) Treat socket.error(EPIPE) as a ConnectionReset (bug #1047325) so
 that clients will properly reconnect. (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
819
819
        self.assertEqual(None, osutils.safe_file_id(None))
820
820
 
821
821
 
822
 
 
823
822
class TestSendAll(tests.TestCase):
824
823
 
 
824
    def test_send_with_disconnected_socket(self):
 
825
        class DisconnectedSocket(object):
 
826
            def __init__(self, err):
 
827
                self.err = err
 
828
            def send(self, content):
 
829
                raise self.err
 
830
            def close(self):
 
831
                pass
 
832
        # All of these should be treated as ConnectionReset
 
833
        errs = []
 
834
        for err_cls in (IOError, socket.error):
 
835
            for errnum in osutils._end_of_stream_errors:
 
836
                errs.append(err_cls(errnum))
 
837
        for err in errs:
 
838
            sock = DisconnectedSocket(err)
 
839
            self.assertRaises(errors.ConnectionReset,
 
840
                osutils.send_all, sock, 'some more content')
 
841
 
825
842
    def test_send_with_no_progress(self):
826
843
        # See https://bugs.launchpad.net/bzr/+bug/1047309
827
844
        # It seems that paramiko can get into a state where it doesn't error,