summaryrefslogtreecommitdiff
path: root/Lib/test/test_asyncio/test_selector_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-01-29 02:56:05 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-01-29 02:56:05 +0100
commit47bbea712415e79ee224d21e518470ec70477d41 (patch)
tree93434368046d4a68f30404adfb29b100cb1d6298 /Lib/test/test_asyncio/test_selector_events.py
parent7b5a900e88a046b01eebafdc98ee23d531c101d3 (diff)
downloadcpython-git-47bbea712415e79ee224d21e518470ec70477d41.tar.gz
asyncio: sync with Tulip
* _SelectorTransport constructor: extra parameter is now optional * Fix _SelectorDatagramTransport constructor. Only start reading after connection_made() has been called. * Fix _SelectorSslTransport.close(). Don't call protocol.connection_lost() if protocol.connection_made() was not called yet: if the SSL handshake failed or is still in progress. The close() method can be called if the creation of the connection is cancelled, by a timeout for example.
Diffstat (limited to 'Lib/test/test_asyncio/test_selector_events.py')
-rw-r--r--Lib/test/test_asyncio/test_selector_events.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_asyncio/test_selector_events.py b/Lib/test/test_asyncio/test_selector_events.py
index 5152616395..f64e40dafc 100644
--- a/Lib/test/test_asyncio/test_selector_events.py
+++ b/Lib/test/test_asyncio/test_selector_events.py
@@ -1427,7 +1427,7 @@ class SelectorSslTransportTests(test_utils.TestCase):
self.assertFalse(tr.can_write_eof())
self.assertRaises(NotImplementedError, tr.write_eof)
- def test_close(self):
+ def check_close(self):
tr = self._make_one()
tr.close()
@@ -1439,6 +1439,19 @@ class SelectorSslTransportTests(test_utils.TestCase):
self.assertEqual(tr._conn_lost, 1)
self.assertEqual(1, self.loop.remove_reader_count[1])
+ test_utils.run_briefly(self.loop)
+
+ def test_close(self):
+ self.check_close()
+ self.assertTrue(self.protocol.connection_made.called)
+ self.assertTrue(self.protocol.connection_lost.called)
+
+ def test_close_not_connected(self):
+ self.sslsock.do_handshake.side_effect = ssl.SSLWantReadError
+ self.check_close()
+ self.assertFalse(self.protocol.connection_made.called)
+ self.assertFalse(self.protocol.connection_lost.called)
+
@unittest.skipIf(ssl is None, 'No SSL support')
def test_server_hostname(self):
self.ssl_transport(server_hostname='localhost')