828
828
self.assertEqual(None, osutils.safe_file_id(None))
831
class TestSendAll(tests.TestCase):
833
def test_send_with_disconnected_socket(self):
834
class DisconnectedSocket(object):
835
def __init__(self, err):
837
def send(self, content):
841
# All of these should be treated as ConnectionReset
843
for err_cls in (IOError, socket.error):
844
for errnum in osutils._end_of_stream_errors:
845
errs.append(err_cls(errnum))
847
sock = DisconnectedSocket(err)
848
self.assertRaises(errors.ConnectionReset,
849
osutils.send_all, sock, 'some more content')
851
def test_send_with_no_progress(self):
852
# See https://bugs.launchpad.net/bzr/+bug/1047309
853
# It seems that paramiko can get into a state where it doesn't error,
854
# but it returns 0 bytes sent for requests over and over again.
855
class NoSendingSocket(object):
858
def send(self, bytes):
860
if self.call_count > 100:
861
# Prevent the test suite from hanging
862
raise RuntimeError('too many calls')
864
sock = NoSendingSocket()
865
self.assertRaises(errors.ConnectionReset,
866
osutils.send_all, sock, 'content')
867
self.assertEqual(1, sock.call_count)
831
870
class TestPosixFuncs(tests.TestCase):
832
871
"""Test that the posix version of normpath returns an appropriate path
833
872
when used with 2 leading slashes."""