[tor-commits] [stem/master] Fix interpreter unit tests

atagar at torproject.org atagar at torproject.org
Sat May 27 20:10:45 UTC 2017


commit 073156e54b4f03c810ee5a0ca93df914bb3095b2
Author: Damian Johnson <atagar at torproject.org>
Date:   Sat May 27 12:35:13 2017 -0700

    Fix interpreter unit tests
    
    Oops, prior change broke one of our assertions.
---
 test/unit/interpreter/commands.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/test/unit/interpreter/commands.py b/test/unit/interpreter/commands.py
index 020b14b..717614e 100644
--- a/test/unit/interpreter/commands.py
+++ b/test/unit/interpreter/commands.py
@@ -91,10 +91,15 @@ class TestInterpreterCommands(unittest.TestCase):
 
   def test_when_disconnected(self):
     controller = Mock()
-    controller.is_alive.return_value = False
+    controller.msg.side_effect = stem.SocketClosed('kaboom!')
 
     interpreter = ControlInterpreter(controller)
-    self.assertRaises(stem.SocketClosed, interpreter.run_command, '/help')
+
+    # we should be able to run non-tor commands
+    self.assertTrue('Interpreter commands include:' in interpreter.run_command('/help'))
+
+    # ... but tor commands should provide exceptions
+    self.assertRaises(stem.SocketClosed, interpreter.run_command, 'GETINFO version')
 
   def test_quit(self):
     interpreter = ControlInterpreter(CONTROLLER)





More information about the tor-commits mailing list