[tor-commits] [stem/master] Unit test broken by get_port() type change

atagar at torproject.org atagar at torproject.org
Thu Jul 23 22:49:44 UTC 2020


commit dd623ddeb74cee802135457a199222ef330ece24
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Jul 23 15:47:20 2020 -0700

    Unit test broken by get_port() type change
    
    Oops, just ran the integ tests prior to pushing. Type change broke a unit test.
    
      ======================================================================
      FAIL: test_get_ports
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/home/atagar/Python-3.7.0/Lib/unittest/mock.py", line 1191, in patched
          return func(*args, **keywargs)
        File "/home/atagar/Desktop/stem/test/unit/control/controller.py", line 231, in test_get_ports
          self.assertEqual([9050], self.controller.get_ports(Listener.CONTROL))
      AssertionError: [9050] != {9050}
    
      ----------------------------------------------------------------------
---
 test/unit/control/controller.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py
index f1ad9209..3367b3d3 100644
--- a/test/unit/control/controller.py
+++ b/test/unit/control/controller.py
@@ -228,7 +228,7 @@ class TestControl(unittest.TestCase):
     get_conf_mock.side_effect = get_conf_mock_side_effect
 
     self.assertEqual([('127.0.0.1', 9050)], self.controller.get_listeners(Listener.CONTROL))
-    self.assertEqual([9050], self.controller.get_ports(Listener.CONTROL))
+    self.assertEqual(set([9050]), self.controller.get_ports(Listener.CONTROL))
     self.controller.clear_cache()
 
     # non-local addresss
@@ -242,7 +242,7 @@ class TestControl(unittest.TestCase):
     get_conf_mock.side_effect = get_conf_mock_side_effect
 
     self.assertEqual([('27.4.4.1', 9050)], self.controller.get_listeners(Listener.CONTROL))
-    self.assertEqual([], self.controller.get_ports(Listener.CONTROL))
+    self.assertEqual(set(), self.controller.get_ports(Listener.CONTROL))
     self.controller.clear_cache()
 
     # exercise via the GETINFO option
@@ -255,7 +255,7 @@ class TestControl(unittest.TestCase):
       self.controller.get_listeners(Listener.CONTROL)
     )
 
-    self.assertEqual([1112, 1114], self.controller.get_ports(Listener.CONTROL))
+    self.assertEqual(set([1112, 1114]), self.controller.get_ports(Listener.CONTROL))
     self.controller.clear_cache()
 
     # with all localhost addresses, including a couple that aren't
@@ -263,7 +263,7 @@ class TestControl(unittest.TestCase):
     listeners = '"27.4.4.1:1113" "127.0.0.5:1114" "0.0.0.0:1115" "[::]:1116" "[::1]:1117" "[10::]:1118"'
     get_info_mock.side_effect = coro_func_returning_value(listeners)
 
-    self.assertEqual([1114, 1115, 1116, 1117], self.controller.get_ports(Listener.OR))
+    self.assertEqual(set([1114, 1115, 1116, 1117]), self.controller.get_ports(Listener.OR))
     self.controller.clear_cache()
 
     # IPv6 address
@@ -282,7 +282,7 @@ class TestControl(unittest.TestCase):
     get_info_mock.side_effect = coro_func_returning_value('"unix:/tmp/tor/socket"')
 
     self.assertEqual([], self.controller.get_listeners(Listener.CONTROL))
-    self.assertEqual([], self.controller.get_ports(Listener.CONTROL))
+    self.assertEqual(set(), self.controller.get_ports(Listener.CONTROL))
 
   @patch('stem.control.Controller.get_info')
   @patch('time.time', Mock(return_value = 1410723598.276578))



More information about the tor-commits mailing list