181
181
shape = sorted(os.listdir('.'))
182
182
self.assertEquals(['A', 'B'], shape)
184
def test_rename_exception(self):
186
osutils.rename('nonexistent_path', 'different_nonexistent_path')
188
self.assertEqual(e.old_filename, 'nonexistent_path')
189
self.assertEqual(e.new_filename, 'different_nonexistent_path')
190
self.assertTrue('nonexistent_path' in e.strerror)
191
self.assertTrue('different_nonexistent_path' in e.strerror)
194
185
class TestRandChars(tests.TestCase):
828
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)
831
861
class TestPosixFuncs(tests.TestCase):
832
862
"""Test that the posix version of normpath returns an appropriate path
833
863
when used with 2 leading slashes."""