[tor-commits] [stem/master] Unit tests didn't account for ending newlines

atagar at torproject.org atagar at torproject.org
Tue May 6 01:34:45 UTC 2014


commit 6622eabc36b795c771afd7913c94273c3c6f1e6a
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon May 5 18:34:28 2014 -0700

    Unit tests didn't account for ending newlines
    
    Oops, last minute change added a newline to the end of non-interpretor
    commands. Forgot to update the unit tests to account for this.
---
 test/unit/interpretor/commands.py |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/test/unit/interpretor/commands.py b/test/unit/interpretor/commands.py
index 9ed7a92..0466e30 100644
--- a/test/unit/interpretor/commands.py
+++ b/test/unit/interpretor/commands.py
@@ -37,6 +37,7 @@ moria1 (9695DFC35FFEB861329B9F1AB04C46397020CE31)
 EXPECTED_GETCONF_RESPONSE = """\
 \x1b[34;1mlog\x1b[0m\x1b[34m => notice stdout\x1b[0m
 \x1b[34;1maddress\x1b[0m\x1b[34m => \x1b[0m
+
 """
 
 FINGERPRINT = '9695DFC35FFEB861329B9F1AB04C46397020CE31'
@@ -171,15 +172,15 @@ class TestInterpretorCommands(unittest.TestCase):
     interpretor = ControlInterpretor(controller)
 
     getinfo['version'] = '0.2.5.1-alpha-dev (git-245ecfff36c0cecc)'
-    self.assertEqual('\x1b[34m0.2.5.1-alpha-dev (git-245ecfff36c0cecc)\x1b[0m', interpretor.run_command('GETINFO version'))
+    self.assertEqual('\x1b[34m0.2.5.1-alpha-dev (git-245ecfff36c0cecc)\x1b[0m\n', interpretor.run_command('GETINFO version'))
     controller.get_info.assert_called_with(['version'])
 
     getinfo['process/user'] = 'atagar'
-    self.assertEqual('\x1b[34m0.2.5.1-alpha-dev (git-245ecfff36c0cecc)\natagar\x1b[0m', interpretor.run_command('getinfo version process/user'))
+    self.assertEqual('\x1b[34m0.2.5.1-alpha-dev (git-245ecfff36c0cecc)\natagar\x1b[0m\n', interpretor.run_command('getinfo version process/user'))
     controller.get_info.assert_called_with(['version', 'process/user'])
 
     controller.get_info.side_effect = stem.ControllerError('kaboom!')
-    self.assertEqual('\x1b[1;31mkaboom!\x1b[0m', interpretor.run_command('getinfo process/user'))
+    self.assertEqual('\x1b[1;31mkaboom!\x1b[0m\n', interpretor.run_command('getinfo process/user'))
 
   def test_getconf(self):
     controller, getconf = Mock(), collections.OrderedDict()
@@ -197,14 +198,14 @@ class TestInterpretorCommands(unittest.TestCase):
     controller = Mock()
     interpretor = ControlInterpretor(controller)
 
-    self.assertEqual('', interpretor.run_command('SETCONF ControlPort=9051'))
+    self.assertEqual('\n', interpretor.run_command('SETCONF ControlPort=9051'))
     controller.set_options.assert_called_with([('ControlPort', '9051')], False)
 
   def test_setevents(self):
     controller = Mock()
     interpretor = ControlInterpretor(controller)
 
-    self.assertEqual('\x1b[34mListing for BW events\n\x1b[0m', interpretor.run_command('SETEVENTS BW'))
+    self.assertEqual('\x1b[34mListing for BW events\n\x1b[0m\n', interpretor.run_command('SETEVENTS BW'))
     controller.add_event_listener.assert_called_with(interpretor.register_event, 'BW')
 
   def test_raw_commands(self):
@@ -212,5 +213,5 @@ class TestInterpretorCommands(unittest.TestCase):
     controller.msg.return_value = 'response'
     interpretor = ControlInterpretor(controller)
 
-    self.assertEqual('\x1b[34mresponse\x1b[0m', interpretor.run_command('NEW_COMMAND spiffyness'))
+    self.assertEqual('\x1b[34mresponse\x1b[0m\n', interpretor.run_command('NEW_COMMAND spiffyness'))
     controller.msg.assert_called_with('NEW_COMMAND spiffyness')



More information about the tor-commits mailing list