Skip to content

Commit

Permalink
test for connections leak
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jan 23, 2015
1 parent 07cd477 commit 54c5423
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ CHANGES
0.14.2 (Unreleased)
-------------------

- Connections leak in BaseConnector #253

- Do not swallow websocket reader exceptions #255

- web.Request's read, text, json are memorized #250
Expand Down
16 changes: 16 additions & 0 deletions tests/test_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@ def test_release_close(self):
self.assertFalse(conn._conns)
self.assertTrue(tr.close.called)

def test_release_close_do_not_delete_existing_connections(self):
key = 1
tr1, proto1 = unittest.mock.Mock(), unittest.mock.Mock()

conn = aiohttp.BaseConnector(share_cookies=True, loop=self.loop)
conn._conns[key] = [(tr1, proto1, 1)]
req = unittest.mock.Mock()
resp = unittest.mock.Mock()
resp.message.should_close = True
req.response = resp

tr, proto = unittest.mock.Mock(), unittest.mock.Mock()
conn._release(key, req, tr, proto)
self.assertEqual(conn._conns[key], [(tr1, proto1, 1)])
self.assertTrue(tr.close.called)

@mock.patch('aiohttp.connector.time')
def test_release_not_started(self, m_time):
m_time.time.return_value = 10
Expand Down

0 comments on commit 54c5423

Please sign in to comment.