Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7784 closed enhancement (implemented)

add Controller.get_socks_port

Reported by: robinson Owned by: atagar
Priority: Medium Milestone:
Component: Archived/Stem Version:
Severity: Keywords: controller
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


Add a Controller method to retrieve the SOCKS port. Please pull this branch.

Child Tickets

Change History (2)

comment:1 Changed 8 years ago by atagar

Resolution: implemented
Status: newclosed

Hi Sean, sorry about the delay! Been busy with the holidays and work.

Pushed your changes with some changes...

It's a pity that the mocking key/value entries need to be alphabetical. That seems like something that'll bite us, but I'm not spotting a nicer way of handling it offhand. Oh well.

comment:2 Changed 8 years ago by robinson

Just to document "Also, remove the the space in the join so that there is only one parameter passed to the string substitution." better:

I was getting an unhelpful error with the following code:

import stem.socket

from stem import InvalidArguments
from stem.control import Controller

from test import mocking

socket = stem.socket.ControlSocket()
controller = Controller(socket)

mocking.mock_method(Controller, "get_info", mocking.raise_exception(InvalidArguments))

mocking.mock_method(Controller, "get_conf", mocking.return_for_args({
  ("SocksPort", "useless_second", "useless_third"): "9050",
  ("SocksListenAddress", "multiple=True"): [""]
}, is_method = True))


Old error:

Traceback (most recent call last):
  File "./", line 19, in <module>
  File "stem/", line 1348, in get_socks_listeners
    socks_port = self.get_conf('SocksPort')
  File "test/", line 360, in <lambda>
    mock_wrapper = lambda *args, **kwargs: mock_call(*args, **kwargs)
  File "test/", line 261, in _return_value
    raise ValueError("Unrecognized argument sent for return_for_args(). Got '%s' but we
only recognize '%s'." % (arg_label, ", ".join(args_to_return_value.keys())))
TypeError: sequence item 0: expected string, tuple found

I mistakenly believed this was due to spaces in the keys in args_to_return_value, but really is was the tuple-as-key did not work in the string substitution. But, I over-corrected. Damian's revision of my fix works and gives readable output.

Note: See TracTickets for help on using tickets.