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