summaryrefslogtreecommitdiff
path: root/t/unit
diff options
context:
space:
mode:
Diffstat (limited to 't/unit')
-rw-r--r--t/unit/test_connection.py13
-rw-r--r--t/unit/test_transport.py11
2 files changed, 19 insertions, 5 deletions
diff --git a/t/unit/test_connection.py b/t/unit/test_connection.py
index 21faebd..a2997e6 100644
--- a/t/unit/test_connection.py
+++ b/t/unit/test_connection.py
@@ -323,10 +323,17 @@ class test_Connection:
channel.collect.assert_called_with()
assert self.conn._transport is None
- def test_collect__channel_raises_socket_error(self):
- self.conn.channels = self.conn.channels = {1: Mock(name='c1')}
- self.conn.channels[1].collect.side_effect = socket.error()
+ def test_collect__transport_socket_raises_os_error(self):
+ self.conn.transport = TCPTransport('localhost:5672')
+ sock = self.conn.transport.sock = Mock(name='sock')
+ channel = Mock(name='c1')
+ self.conn.channels = {1: channel}
+ sock.shutdown.side_effect = OSError
self.conn.collect()
+ channel.collect.assert_called_with()
+ sock.close.assert_called_with()
+ assert self.conn._transport is None
+ assert self.conn.channels is None
def test_collect_no_transport(self):
self.conn = Connection()
diff --git a/t/unit/test_transport.py b/t/unit/test_transport.py
index d93116a..b111497 100644
--- a/t/unit/test_transport.py
+++ b/t/unit/test_transport.py
@@ -282,6 +282,13 @@ class test_AbstractTransport:
self.t.close()
assert self.t.sock is None and self.t.connected is False
+ def test_close_os_error(self):
+ sock = self.t.sock = Mock()
+ sock.shutdown.side_effect = OSError
+ self.t.close()
+ sock.close.assert_called_with()
+ assert self.t.sock is None and self.t.connected is False
+
def test_read_frame__timeout(self):
self.t._read = Mock()
self.t._read.side_effect = socket.timeout()
@@ -719,7 +726,7 @@ class test_SSLTransport:
)
assert context.verify_mode == sentinel.CERT_REQS
- # testing context creation inside _wrap_socket_sni() with parameter
+ # testing context creation inside _wrap_socket_sni() with parameter
# cert_reqs == ssl.CERT_NONE. Previously raised ValueError because
# code path attempted to set context.verify_mode=ssl.CERT_NONE before
# setting context.check_hostname = False which raised a ValueError
@@ -740,7 +747,7 @@ class test_SSLTransport:
)
mock_load_default_certs.assert_not_called()
mock_wrap_socket.assert_called_once()
-
+
with patch('ssl.SSLContext.wrap_socket') as mock_wrap_socket:
with patch('ssl.SSLContext.load_default_certs') as mock_load_default_certs:
sock = Mock()