[tor-commits] [stem/master] Capitalize test.network constants

atagar at torproject.org atagar at torproject.org
Sat Mar 24 00:59:33 UTC 2018


commit c5c095c791ab6d379524742464f99be256fd6685
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Mar 23 13:51:09 2018 -0700

    Capitalize test.network constants
---
 test/integ/control/controller.py | 2 +-
 test/network.py                  | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 5f823eea..e73218da 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -1134,7 +1134,7 @@ class TestController(unittest.TestCase):
           s.settimeout(30)
           s.connect(('127.0.0.1', int(controller.get_conf('SocksPort'))))
           test.network.negotiate_socks(s, '1.2.1.2', 80)
-          s.sendall(stem.util.str_tools._to_bytes(test.network.ip_request))  # make the http request for the ip address
+          s.sendall(stem.util.str_tools._to_bytes(test.network.IP_REQUEST))  # make the http request for the ip address
           response = s.recv(1000)
 
           if response:
diff --git a/test/network.py b/test/network.py
index dfb0a05e..05f51cd6 100644
--- a/test/network.py
+++ b/test/network.py
@@ -34,14 +34,14 @@ SOCKS5_CONN_BY_IPV4 = (0x05, 0x01, 0x00, 0x01)
 SOCKS5_CONN_BY_NAME = (0x05, 0x01, 0x00, 0x03)
 
 
-error_msgs = {
+ERROR_MSG = {
   0x5a: 'SOCKS4A request granted',
   0x5b: 'SOCKS4A request rejected or failed',
   0x5c: 'SOCKS4A request failed because client is not running identd (or not reachable from the server)',
   0x5d: "SOCKS4A request failed because client's identd could not confirm the user ID string in the request",
 }
 
-ip_request = """GET /ip HTTP/1.0
+IP_REQUEST = """GET /ip HTTP/1.0
 Host: ifconfig.me
 Accept-Encoding: identity
 
@@ -300,7 +300,7 @@ def external_ip(host, port):
 
   try:
     negotiate_socks(sock, 'ifconfig.me', 80)
-    sock.sendall(ip_request)
+    sock.sendall(IP_REQUEST)
     response = sock.recv(1000)
 
     # everything after the blank line is the 'data' in a HTTP response
@@ -332,6 +332,6 @@ def negotiate_socks(sock, host, port):
 
   if len(response) != 8 or response[0:2] != b'\x00\x5a':
     sock.close()
-    raise ProtocolError(error_msgs.get(response[1], 'SOCKS server returned unrecognized error code'))
+    raise ProtocolError(ERROR_MSG.get(response[1], 'SOCKS server returned unrecognized error code'))
 
   return [socket.inet_ntoa(response[4:]), struct.unpack('!H', response[2:4])[0]]





More information about the tor-commits mailing list