MCPcopy
hub / github.com/aio-libs/aiohttp / test_cleanup

Method test_cleanup

tests/test_connector.py:322–340  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

320 12, conn._cleanup)
321
322 def test_cleanup(self):
323 testset = {
324 1: [(unittest.mock.Mock(), unittest.mock.Mock(), 10),
325 (unittest.mock.Mock(), unittest.mock.Mock(), 300),
326 (None, unittest.mock.Mock(), 300)],
327 }
328 testset[1][0][1].is_connected.return_value = True
329 testset[1][1][1].is_connected.return_value = False
330
331 loop = unittest.mock.Mock()
332 loop.time.return_value = 300
333 conn = aiohttp.BaseConnector(loop=loop)
334 conn._conns = testset
335 existing_handle = conn._cleanup_handle = unittest.mock.Mock()
336
337 conn._cleanup()
338 self.assertTrue(existing_handle.cancel.called)
339 self.assertEqual(conn._conns, {})
340 self.assertIsNone(conn._cleanup_handle)
341
342 def test_cleanup2(self):
343 testset = {1: [(unittest.mock.Mock(), unittest.mock.Mock(), 300)]}

Callers

nothing calls this directly

Calls 1

_cleanupMethod · 0.95

Tested by

no test coverage detected