[tor-commits] [stem/master] Stylistic adjustments

atagar at torproject.org atagar at torproject.org
Mon Oct 7 02:39:02 UTC 2019


commit beba313269d087fc569d3a4b1ccc1e98ba6c210d
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Oct 6 19:05:38 2019 -0700

    Stylistic adjustments
    
    Mostly just fixups for pycodestyle...
    
      STATIC CHECKS
      * /home/atagar/Desktop/stem/test/integ/control/controller.py
        line 1126 - E303 too many blank lines (2)            | @test.require.controller
        line 1151 - use single rather than double quotes     | self.assertTrue(addr1.startswith("127."),
        line 1152 - use single rather than double quotes     | "%s did not start with 127."%addr1)
        line 1152 - E228 missing whitespace around modulo operator | "%s did not start with 127."%addr1)
        line 1153 - use single rather than double quotes     | self.assertEquals(target, "quux")
        line 1161 - use single rather than double quotes     | self.assertTrue(addr2.startswith("[fe"),
        line 1162 - use single rather than double quotes     | "%s did not start with [fe."%addr2)
        line 1162 - E228 missing whitespace around modulo operator | "%s did not start with [fe."%addr2)
        line 1163 - use single rather than double quotes     | self.assertEquals(target, "quibble")
        line 1169 - use single rather than double quotes     | for line in s.split("\n"):
        line 1170 - E701 multiple statements on one line (colon) | if not line.strip(): continue
        line 1171 - E231 missing whitespace after ','        | k,v,timeout = line.split()
        line 1178 - use single rather than double quotes     | self.assertEquals(m["1.2.1.2"], "ifconfig.me")
        line 1179 - use single rather than double quotes     | self.assertEquals(m["1.2.3.4"], "foobar.example.com")
        line 1180 - use single rather than double quotes     | self.assertEquals(m["1.2.3.5"], "barfuzz.example.com")
        line 1181 - use single rather than double quotes     | self.assertEquals(m[addr1], "quux")
        line 1182 - use single rather than double quotes     | self.assertEquals(m[addr2], "quibble")
        line 1187 - use single rather than double quotes     | self.assertEquals(m["1.2.1.2"], "ifconfig.me")
        line 1188 - use single rather than double quotes     | self.assertEquals(m["1.2.3.4"], "foobar.example.com")
        line 1189 - use single rather than double quotes     | self.assertEquals(m["1.2.3.5"], "barfuzz.example.com")
        line 1190 - use single rather than double quotes     | self.assertEquals(m[addr1], "quux")
        line 1191 - use single rather than double quotes     | self.assertEquals(m[addr2], "quibble")
        line 1197 - use single rather than double quotes     | self.assertEquals(m.get("1.2.1.2"), None)
        line 1198 - use single rather than double quotes     | self.assertEquals(m.get("1.2.3.4"), None)
---
 test/integ/control/controller.py | 66 +++++++++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 24 deletions(-)

diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 3980a318..c7394575 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -1122,80 +1122,98 @@ class TestController(unittest.TestCase):
       ip_addr = response[response.find(b'\r\n\r\n'):].strip()
       self.assertTrue(stem.util.connection.is_valid_ipv4_address(stem.util.str_tools._to_unicode(ip_addr)), "'%s' isn't an address" % ip_addr)
 
-
   @test.require.controller
   def test_mapaddress_offline(self):
     runner = test.runner.get_runner()
 
     with runner.get_tor_controller() as controller:
       # Try mapping one element, make sure the result is as expected.
+
       map1 = {'1.2.1.2': 'ifconfig.me'}
       x = controller.map_address(map1)
       self.assertEqual(x, map1)
 
       # Try mapping two elements, make sure the result is as expected.
+
       map2 = {'1.2.3.4': 'foobar.example.com',
               '1.2.3.5': 'barfuzz.example.com'}
+
       x = controller.map_address(map2)
       self.assertEqual(x, map2)
 
       # Try mapping zero elements, get an error.
+
       self.assertRaises(stem.InvalidRequest, controller.map_address, {})
 
       # Try a virtual mapping to IPv4
+
       map3 = {'0.0.0.0': 'quux'}
       x = controller.map_address(map3)
       self.assertEquals(len(x), 1)
-      (addr1, target) = list(x.items())[0]
+      addr1, target = list(x.items())[0]
+
       # The default IPv4 virtualaddressrange is 127.192.0.0/10
-      self.assertTrue(addr1.startswith("127."),
-                      "%s did not start with 127."%addr1)
-      self.assertEquals(target, "quux")
+
+      self.assertTrue(addr1.startswith('127.'), '%s did not start with 127.' % addr1)
+      self.assertEquals(target, 'quux')
 
       # Try a virtual mapping to IPv6
+
       map4 = {'::': 'quibble'}
       x = controller.map_address(map4)
       self.assertEquals(len(x), 1)
-      (addr2, target) = list(x.items())[0]
+      addr2, target = list(x.items())[0]
+
       # The default IPv6 virtualaddressrange is FE80::/10
-      self.assertTrue(addr2.startswith("[fe"),
-                      "%s did not start with [fe."%addr2)
-      self.assertEquals(target, "quibble")
+
+      self.assertTrue(addr2.startswith('[fe'), '%s did not start with [fe.' % addr2)
+      self.assertEquals(target, 'quibble')
 
       def parse_mapping_list(s):
         # Helper function -- parse the response from getinfo address-mappings
         # into a dict.
+
         result = dict()
-        for line in s.split("\n"):
-          if not line.strip(): continue
-          k,v,timeout = line.split()
+
+        for line in s.split('\n'):
+          if not line.strip():
+            continue
+
+          k, v, timeout = line.split()
           result[k] = v
+
         return result
 
       # Ask for a list of all the address mappings we've added.
+
       x = controller.get_info(['address-mappings/control'])
       m = parse_mapping_list(x['address-mappings/control'])
-      self.assertEquals(m["1.2.1.2"], "ifconfig.me")
-      self.assertEquals(m["1.2.3.4"], "foobar.example.com")
-      self.assertEquals(m["1.2.3.5"], "barfuzz.example.com")
-      self.assertEquals(m[addr1], "quux")
-      self.assertEquals(m[addr2], "quibble")
+
+      self.assertEquals(m['1.2.1.2'], 'ifconfig.me')
+      self.assertEquals(m['1.2.3.4'], 'foobar.example.com')
+      self.assertEquals(m['1.2.3.5'], 'barfuzz.example.com')
+      self.assertEquals(m[addr1], 'quux')
+      self.assertEquals(m[addr2], 'quibble')
 
       # Ask for a list of all the address mappings.
+
       x = controller.get_info(['address-mappings/all'])
       m = parse_mapping_list(x['address-mappings/all'])
-      self.assertEquals(m["1.2.1.2"], "ifconfig.me")
-      self.assertEquals(m["1.2.3.4"], "foobar.example.com")
-      self.assertEquals(m["1.2.3.5"], "barfuzz.example.com")
-      self.assertEquals(m[addr1], "quux")
-      self.assertEquals(m[addr2], "quibble")
+
+      self.assertEquals(m['1.2.1.2'], 'ifconfig.me')
+      self.assertEquals(m['1.2.3.4'], 'foobar.example.com')
+      self.assertEquals(m['1.2.3.5'], 'barfuzz.example.com')
+      self.assertEquals(m[addr1], 'quux')
+      self.assertEquals(m[addr2], 'quibble')
 
       # Now ask for a list of only the mappings configured with the
       # configuration.  Ours should not be there.
+
       x = controller.get_info(['address-mappings/config'])
       m = parse_mapping_list(x['address-mappings/config'])
-      self.assertEquals(m.get("1.2.1.2"), None)
-      self.assertEquals(m.get("1.2.3.4"), None)
+
+      self.assertEquals(m.get('1.2.1.2'), None)
+      self.assertEquals(m.get('1.2.3.4'), None)
       self.assertEquals(m.get(addr1), None)
       self.assertEquals(m.get(addr2), None)
 





More information about the tor-commits mailing list