Message integ tests compatability issues

The message integration tests had compatability issues with...
- Newer python versions (2.6 -> 2.7) due to an unexpected failure when calling
  close() on the socket's file object. We're operating with a closed socket at
  that time so all bets are off about if this should/shouldn't raise so the
  difference in behavior just warranted a testing workaround.

- Older tor versions don't support 'GETINFO config-text'. I've left this as a
  TODO note for now and will add a version check for that test later.
This commit is contained in:
Damian Johnson 2011-10-20 09:49:45 -07:00
parent 1b44b967e7
commit 26374bafd5

View File

@ -60,15 +60,20 @@ class TestMessageFunctions(unittest.TestCase):
self.assertRaises(stem.types.ControlSocketClosed, stem.types.read_message, control_socket_file)
# Closing the file handler, however, will cause a different type of error.
# This seems to depend on the python version, in 2.6 we get an
# AttributeError and in 2.7 the close() call raises...
# error: [Errno 32] Broken pipe
control_socket_file.close()
control_socket_file.write("GETINFO version\r\n")
# receives: AttributeError: 'NoneType' object has no attribute 'sendall'
self.assertRaises(AttributeError, control_socket_file.flush)
# receives: stem.types.ControlSocketClosed: socket file has been closed
self.assertRaises(stem.types.ControlSocketClosed, stem.types.read_message, control_socket_file)
try:
control_socket_file.close()
control_socket_file.write("GETINFO version\r\n")
# receives: AttributeError: 'NoneType' object has no attribute 'sendall'
self.assertRaises(AttributeError, control_socket_file.flush)
# receives: stem.types.ControlSocketClosed: socket file has been closed
self.assertRaises(stem.types.ControlSocketClosed, stem.types.read_message, control_socket_file)
except: pass
def test_invalid_command(self):
"""
@ -135,6 +140,9 @@ class TestMessageFunctions(unittest.TestCase):
Parses the 'GETINFO config-text' response.
"""
# TODO: add a 0.2.2.7-alpha version check for this test (that was when
# 'GETINFO config-text' was added)
# We can't be certain of the order, and there may be extra config-text
# entries as per...
# https://trac.torproject.org/projects/tor/ticket/2362