[stem/master] Minor revisions for the new add_event_listener tests

commit 3be3a8d94bb666b56bdc65e732f83c88ccfe0a15 Author: Damian Johnson <atagar@torproject.org> Date: Sun Dec 9 13:52:20 2012 -0800 Minor revisions for the new add_event_listener tests Just some minor tweaks... * Replaced 'lambda x: x' with 'mocking.no_op()'. * Dropped the 'assertIsNone()' call. The purpose of this line is to make sure that add_event_listener() doesn't raise an exception, not to make an assertion on what the function returns. * Minor import tweaks to conform with 3da47d3. --- test/unit/control/controller.py | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-) diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py index a9d31d1..400d795 100644 --- a/test/unit/control/controller.py +++ b/test/unit/control/controller.py @@ -5,11 +5,12 @@ integ tests, but a few bits lend themselves to unit testing. import unittest -from stem import InvalidRequest, ProtocolError -from stem.control import _parse_circ_path, Controller, EventType import stem.socket import stem.version -import test.mocking as mocking + +from stem import InvalidRequest, ProtocolError +from stem.control import _parse_circ_path, Controller, EventType +from test import mocking class TestControl(unittest.TestCase): def setUp(self): @@ -65,12 +66,14 @@ class TestControl(unittest.TestCase): # set up for failure to create any events mocking.mock_method(Controller, "get_version", mocking.return_value(stem.version.Version('0.1.0.14'))) - self.assertRaises(InvalidRequest, self.controller.add_event_listener, lambda x: x, EventType.BW) + self.assertRaises(InvalidRequest, self.controller.add_event_listener, mocking.no_op(), EventType.BW) # set up to only fail newer events mocking.mock_method(Controller, "get_version", mocking.return_value(stem.version.Version('0.2.0.35'))) + # EventType.BW is one of the earliest events - self.assertIsNone(self.controller.add_event_listener(lambda x: x, EventType.BW)) + self.controller.add_event_listener(mocking.no_op(), EventType.BW) + # EventType.SIGNAL was added in tor version 0.2.3.1-alpha - self.assertRaises(InvalidRequest, self.controller.add_event_listener, lambda x: x, EventType.SIGNAL) + self.assertRaises(InvalidRequest, self.controller.add_event_listener, mocking.no_op(), EventType.SIGNAL)
participants (1)
-
atagar@torproject.org