Skip to content

Commit 54c5423

Browse files
committed
test for connections leak
1 parent 07cd477 commit 54c5423

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGES
44
0.14.2 (Unreleased)
55
-------------------
66

7+
- Connections leak in BaseConnector #253
8+
79
- Do not swallow websocket reader exceptions #255
810

911
- web.Request's read, text, json are memorized #250

tests/test_connector.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ def test_release_close(self):
184184
self.assertFalse(conn._conns)
185185
self.assertTrue(tr.close.called)
186186

187+
def test_release_close_do_not_delete_existing_connections(self):
188+
key = 1
189+
tr1, proto1 = unittest.mock.Mock(), unittest.mock.Mock()
190+
191+
conn = aiohttp.BaseConnector(share_cookies=True, loop=self.loop)
192+
conn._conns[key] = [(tr1, proto1, 1)]
193+
req = unittest.mock.Mock()
194+
resp = unittest.mock.Mock()
195+
resp.message.should_close = True
196+
req.response = resp
197+
198+
tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
199+
conn._release(key, req, tr, proto)
200+
self.assertEqual(conn._conns[key], [(tr1, proto1, 1)])
201+
self.assertTrue(tr.close.called)
202+
187203
@mock.patch('aiohttp.connector.time')
188204
def test_release_not_started(self, m_time):
189205
m_time.time.return_value = 10

0 commit comments

Comments
 (0)