[tor-dev] stem mock_method usage
atagar at torproject.org
Sat Dec 8 02:22:39 UTC 2012
Hi Sean. You're using the mock_method() function correctly...
f = Foo()
mocking.mock_method(Foo, 'greeting', mocking.return_value('bye'))
atagar at morrigan:~/Desktop/stem$ python example.py
The trouble is that the Controller __dict__ is a dictproxy (a
read-only dictionary). After some experimentation this seems to be a
product of extending object...
>>> class Foo:
>>> class Bar(object):
So... um, shame on us for doing the right thing. ;)
We've probably never encountered this before because the mock_method()
function is presently completely unused...
atagar at morrigan:~/Desktop/stem$ grep -Rl "mock_method" * | grep -v '.pyc'
It was added in a500dbc to help test the BaseController, then its
usage was removed in 4ff7efe. Strangely method mocking hasn't come up
again since then. Unfortunately I don't have a good suggestion on how
to work around this...
More information about the tor-dev