[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Exercising is_alive in ControlMessage integ tests



commit 2ae0298e816ccb70bf9ab52996a4c78e26f897f0
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Jan 31 09:23:31 2012 -0800

    Exercising is_alive in ControlMessage integ tests
    
    Adding a basic check for the is_alive method. The method is a little troubesome
    because if you aren't continually pulling from the socket then you won't detect
    a disconnect until the following usage.
    
    This was already documented and iirc it won't be an issue in practice for
    controllers since they continually pull from the socket. But still, for low
    level controller interaction it's kinda confusing.
---
 test/integ/socket/control_message.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/test/integ/socket/control_message.py b/test/integ/socket/control_message.py
index ce25c8f..2eb2a6e 100644
--- a/test/integ/socket/control_message.py
+++ b/test/integ/socket/control_message.py
@@ -36,11 +36,17 @@ class TestControlMessage(unittest.TestCase):
     # an error until we read from the socket. However, with a control socket
     # the write will cause a SocketError.
     
+    self.assertTrue(control_socket.is_alive())
+    
     try:
       control_socket.send("GETINFO version")
     except: pass
     
+    # at this point is_alive is True with a control port and False with a
+    # control socket
+    
     self.assertRaises(stem.socket.SocketClosed, control_socket.recv)
+    self.assertFalse(control_socket.is_alive())
     
     # Additional socket usage should fail, and pulling more responses will fail
     # with more closed exceptions.

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits