|
|
32e5f0 |
--- a/websockets/test_protocol.py 2017-08-21 19:42:07.788929215 +0200
|
|
|
32e5f0 |
+++ b/websockets/test_protocol.py 2017-08-21 19:42:01.260805760 +0200
|
|
|
32e5f0 |
@@ -741,49 +741,3 @@
|
|
|
32e5f0 |
|
|
|
32e5f0 |
# There is no test_local_close_during_send because this cannot really
|
|
|
32e5f0 |
# happen, considering that writes are serialized.
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
-class ServerTests(CommonTests, unittest.TestCase):
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
- def test_close_handshake_timeout(self):
|
|
|
32e5f0 |
- # Timeout is expected in 10ms.
|
|
|
32e5f0 |
- self.protocol.timeout = 10 * MS
|
|
|
32e5f0 |
- # Check the timing within -1/+9ms for robustness.
|
|
|
32e5f0 |
- with self.assertCompletesWithin(9 * MS, 19 * MS):
|
|
|
32e5f0 |
- # Unlike previous tests, no close frame will be received in
|
|
|
32e5f0 |
- # response. The server will stop waiting for the close frame and
|
|
|
32e5f0 |
- # timeout.
|
|
|
32e5f0 |
- self.loop.run_until_complete(self.protocol.close(reason='close'))
|
|
|
32e5f0 |
- self.assertConnectionClosed(1006, '')
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
-class ClientTests(CommonTests, unittest.TestCase):
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
- def setUp(self):
|
|
|
32e5f0 |
- super().setUp()
|
|
|
32e5f0 |
- self.protocol.is_client = True
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
- def test_close_handshake_timeout(self):
|
|
|
32e5f0 |
- # Timeout is expected in 2 * 10 = 20ms.
|
|
|
32e5f0 |
- self.protocol.timeout = 10 * MS
|
|
|
32e5f0 |
- # Check the timing within -1/+9ms for robustness.
|
|
|
32e5f0 |
- with self.assertCompletesWithin(19 * MS, 29 * MS):
|
|
|
32e5f0 |
- # Unlike previous tests, no close frame will be received in
|
|
|
32e5f0 |
- # response and the connection will not be closed. The client will
|
|
|
32e5f0 |
- # stop waiting for the close frame and timeout, then stop waiting
|
|
|
32e5f0 |
- # for the connection close and timeout again.
|
|
|
32e5f0 |
- self.loop.run_until_complete(self.protocol.close(reason='close'))
|
|
|
32e5f0 |
- self.assertConnectionClosed(1006, '')
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
- def test_eof_received_timeout(self):
|
|
|
32e5f0 |
- # Timeout is expected in 10ms.
|
|
|
32e5f0 |
- self.protocol.timeout = 10 * MS
|
|
|
32e5f0 |
- # Check the timing within -1/+9ms for robustness.
|
|
|
32e5f0 |
- with self.assertCompletesWithin(9 * MS, 19 * MS):
|
|
|
32e5f0 |
- # Unlike previous tests, the close frame will be received in
|
|
|
32e5f0 |
- # response but the connection will not be closed. The client will
|
|
|
32e5f0 |
- # stop waiting for the connection close and timeout.
|
|
|
32e5f0 |
- self.receive_frame(self.close_frame)
|
|
|
32e5f0 |
- self.loop.run_until_complete(self.protocol.close(reason='close'))
|
|
|
32e5f0 |
-
|
|
|
32e5f0 |
- self.assertConnectionClosed(1000, 'close')
|