Rev 6513: Since the code is in osutils, put the tests in there as well. in http://bazaar.launchpad.net/~jameinel/bzr/2.5-conn-reset-socket-pipe-1047325
John Arbash Meinel
john at arbash-meinel.com
Mon Sep 10 11:56:48 UTC 2012
At http://bazaar.launchpad.net/~jameinel/bzr/2.5-conn-reset-socket-pipe-1047325
------------------------------------------------------------
revno: 6513
revision-id: john at arbash-meinel.com-20120910115639-lno6q910yrakt0rf
parent: john at arbash-meinel.com-20120910115158-v2j9ykqorlpu7qwt
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.5-conn-reset-socket-pipe-1047325
timestamp: Mon 2012-09-10 15:56:39 +0400
message:
Since the code is in osutils, put the tests in there as well.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2012-02-28 04:58:14 +0000
+++ b/bzrlib/tests/test_osutils.py 2012-09-10 11:56:39 +0000
@@ -819,6 +819,26 @@
self.assertEqual(None, osutils.safe_file_id(None))
+class TestSendAll(tests.TestCase):
+
+ def test_send_with_disconnected_socket(self):
+ class DisconnectedSocket(object):
+ def __init__(self, err):
+ self.err = err
+ def send(self, content):
+ raise self.err
+ def close(self):
+ pass
+ # All of these should be treated as ConnectionReset
+ errs = []
+ for err_cls in (IOError, socket.error):
+ for errnum in osutils._end_of_stream_errors:
+ errs.append(err_cls(errnum))
+ for err in errs:
+ sock = DisconnectedSocket(err)
+ self.assertRaises(errors.ConnectionReset,
+ osutils.send_all, sock, 'some more content')
+
class TestPosixFuncs(tests.TestCase):
"""Test that the posix version of normpath returns an appropriate path
when used with 2 leading slashes."""
=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py 2012-09-10 11:51:58 +0000
+++ b/bzrlib/tests/test_smart_transport.py 2012-09-10 11:56:39 +0000
@@ -634,25 +634,6 @@
self.assertRaises(
errors.ConnectionError, client_medium._ensure_connection)
- def test_disconnected_socket(self):
- class DisconnectedSocket(object):
- def __init__(self, err):
- self.err = err
- def send(self, content):
- raise self.err
- def close(self):
- pass
- # All of these should be treated as ConnectionReset
- errs = []
- for err_cls in (IOError, socket.error):
- for errnum in osutils._end_of_stream_errors:
- errs.append(err_cls(errnum))
- for err in errs:
- sock = DisconnectedSocket(err)
- med = medium.SmartClientAlreadyConnectedSocketMedium('base', sock)
- self.assertRaises(errors.ConnectionReset,
- med.accept_bytes, 'some more content')
-
class TestSmartClientStreamMediumRequest(tests.TestCase):
"""Tests the for SmartClientStreamMediumRequest.
More information about the bazaar-commits
mailing list