[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Conforming to E261 (at least two spaces before inline comment)
commit 23b06d380c4e2b3e0bfb0348ff03c5685e59754b
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Jan 6 22:37:33 2013 -0800
Conforming to E261 (at least two spaces before inline comment)
---
stem/connection.py | 2 +-
stem/control.py | 12 +++++-----
stem/descriptor/__init__.py | 6 ++--
stem/descriptor/extrainfo_descriptor.py | 14 +++++-----
stem/descriptor/networkstatus.py | 6 ++--
stem/descriptor/reader.py | 2 +-
stem/descriptor/server_descriptor.py | 12 +++++-----
stem/exit_policy.py | 4 +-
stem/process.py | 4 +-
stem/response/__init__.py | 6 ++--
stem/response/getconf.py | 2 +-
stem/socket.py | 8 +++---
stem/util/conf.py | 12 +++++-----
stem/util/connection.py | 10 ++++----
stem/util/proc.py | 4 +-
stem/util/system.py | 8 +++---
stem/version.py | 2 +-
test/check_whitespace.py | 2 +-
test/integ/control/base_controller.py | 2 +-
test/integ/control/controller.py | 2 +-
test/integ/descriptor/extrainfo_descriptor.py | 4 +-
test/integ/descriptor/networkstatus.py | 2 +-
test/integ/descriptor/reader.py | 26 ++++++++++----------
test/integ/descriptor/server_descriptor.py | 12 +++++-----
test/integ/process.py | 6 ++--
test/mocking.py | 6 ++--
test/runner.py | 2 +-
test/unit/control/controller.py | 20 ++++++++--------
test/unit/descriptor/networkstatus/document_v3.py | 10 ++++----
test/unit/descriptor/router_status_entry.py | 6 ++--
test/unit/response/control_message.py | 2 +-
test/unit/response/events.py | 2 +-
test/unit/tutorial.py | 2 +-
test/unit/util/conf.py | 2 +-
test/unit/util/str_tools.py | 4 +-
35 files changed, 113 insertions(+), 113 deletions(-)
diff --git a/stem/connection.py b/stem/connection.py
index ee8f852..737776f 100644
--- a/stem/connection.py
+++ b/stem/connection.py
@@ -370,7 +370,7 @@ def authenticate(controller, password = None, chroot_path = None, protocolinfo_r
else:
authenticate_cookie(controller, cookie_path, False)
- return # success!
+ return # success!
except OpenAuthRejected, exc:
auth_exceptions.append(exc)
except IncorrectPassword, exc:
diff --git a/stem/control.py b/stem/control.py
index c1f1114..fc4af05 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -226,7 +226,7 @@ class BaseController(object):
self._socket = control_socket
self._msg_lock = threading.RLock()
- self._status_listeners = [] # tuples of the form (callback, spawn_thread)
+ self._status_listeners = [] # tuples of the form (callback, spawn_thread)
self._status_listeners_lock = threading.RLock()
# queues where incoming messages are directed
@@ -249,7 +249,7 @@ class BaseController(object):
self._socket._connect = self._connect
self._socket._close = self._close
- self._last_heartbeat = 0.0 # timestamp for when we last heard from tor
+ self._last_heartbeat = 0.0 # timestamp for when we last heard from tor
if self._socket.is_alive():
self._launch_threads()
@@ -293,7 +293,7 @@ class BaseController(object):
response = self._reply_queue.get_nowait()
if isinstance(response, stem.SocketClosed):
- pass # this is fine
+ pass # this is fine
elif isinstance(response, stem.ProtocolError):
log.info("Tor provided a malformed message (%s)" % response)
elif isinstance(response, stem.ControllerError):
@@ -735,7 +735,7 @@ class Controller(BaseController):
if self.is_caching_enabled():
for key, value in response.entries.items():
- key = key.lower() # make case insensitive
+ key = key.lower() # make case insensitive
if key in CACHEABLE_GETINFO_PARAMS:
self._request_cache["getinfo.%s" % key] = value
@@ -821,7 +821,7 @@ class Controller(BaseController):
elif not ':' in listener:
raise stem.ProtocolError("'GETINFO net/listeners/socks' had a listener without a colon: %s" % listener)
- listener = listener[1:-1] # strip quotes
+ listener = listener[1:-1] # strip quotes
addr, port = listener.split(':')
proxy_addrs.append((addr, port))
except stem.InvalidArguments:
@@ -1945,7 +1945,7 @@ def _parse_circ_entry(entry):
if not stem.util.tor_tools.is_valid_fingerprint(fingerprint, True):
raise stem.ProtocolError("Fingerprint in the circuit path is malformed (%s)" % fingerprint)
- fingerprint = fingerprint[1:] # strip off the leading '$'
+ fingerprint = fingerprint[1:] # strip off the leading '$'
if nickname is not None and not stem.util.tor_tools.is_valid_nickname(nickname):
raise stem.ProtocolError("Nickname in the circuit path is malformed (%s)" % nickname)
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index ed74b1f..ed52b42 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -211,7 +211,7 @@ def _read_until_keywords(keywords, descriptor_file, inclusive = False, ignore_fi
break
line = descriptor_file.readline()
- if not line: break # EOF
+ if not line: break # EOF
line_match = KEYWORD_LINE.match(line)
@@ -252,7 +252,7 @@ def _get_pseudo_pgp_block(remaining_contents):
"""
if not remaining_contents:
- return None # nothing left
+ return None # nothing left
block_match = PGP_BLOCK_START.match(remaining_contents[0])
@@ -300,7 +300,7 @@ def _get_descriptor_components(raw_contents, validate, extra_keywords = ()):
"""
entries = OrderedDict()
- extra_entries = [] # entries with a keyword in extra_keywords
+ extra_entries = [] # entries with a keyword in extra_keywords
remaining_lines = raw_contents.split("\n")
while remaining_lines:
diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index 0976943..7ea457c 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -158,7 +158,7 @@ def parse_file(descriptor_file, validate = True):
if extrainfo_content:
yield RelayExtraInfoDescriptor("".join(extrainfo_content), validate)
- else: break # done parsing file
+ else: break # done parsing file
def _parse_timestamp_and_interval(keyword, content):
"""
@@ -180,7 +180,7 @@ def _parse_timestamp_and_interval(keyword, content):
raise ValueError("Malformed %s line: %s" % (keyword, line))
timestamp_str, interval, remainder = content_match.groups()
- if remainder: remainder = remainder[1:] # remove leading space
+ if remainder: remainder = remainder[1:] # remove leading space
if not interval.isdigit():
raise ValueError("%s line's interval wasn't a number: %s" % (keyword, line))
@@ -423,7 +423,7 @@ class ExtraInfoDescriptor(stem.descriptor.Descriptor):
for keyword, values in entries.items():
# most just work with the first (and only) value
value, _ = values[0]
- line = "%s %s" % (keyword, value) # original line
+ line = "%s %s" % (keyword, value) # original line
if keyword == "extra-info":
# "extra-info" Nickname Fingerprint
@@ -800,13 +800,13 @@ class RelayExtraInfoDescriptor(ExtraInfoDescriptor):
return self._digest
def _parse(self, entries, validate):
- entries = dict(entries) # shallow copy since we're destructive
+ entries = dict(entries) # shallow copy since we're destructive
# handles fields only in server descriptors
for keyword, values in entries.items():
value, block_contents = values[0]
- line = "%s %s" % (keyword, value) # original line
+ line = "%s %s" % (keyword, value) # original line
if block_contents: line += "\n%s" % block_contents
if keyword == "router-signature":
@@ -836,12 +836,12 @@ class BridgeExtraInfoDescriptor(ExtraInfoDescriptor):
return self._digest
def _parse(self, entries, validate):
- entries = dict(entries) # shallow copy since we're destructive
+ entries = dict(entries) # shallow copy since we're destructive
# handles fields only in server descriptors
for keyword, values in entries.items():
value, _ = values[0]
- line = "%s %s" % (keyword, value) # original line
+ line = "%s %s" % (keyword, value) # original line
if keyword == "router-digest":
if validate and not stem.util.tor_tools.is_hex_digits(value, 40):
diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py
index 40b3257..2bdfbc4 100644
--- a/stem/descriptor/networkstatus.py
+++ b/stem/descriptor/networkstatus.py
@@ -310,7 +310,7 @@ class NetworkStatusDocumentV2(NetworkStatusDocument):
for keyword, values in entries.items():
value, block_contents = values[0]
- line = "%s %s" % (keyword, value) # original line
+ line = "%s %s" % (keyword, value) # original line
if block_contents: line += "\n%s" % block_contents
if keyword == "network-status-version":
@@ -729,7 +729,7 @@ class _DocumentFooter(object):
if validate and content and not header.meets_consensus_method(9):
raise ValueError("Network status document's footer should only appear in consensus-method 9 or later")
elif not content and not header.meets_consensus_method(9):
- return # footer is optional and there's nothing to parse
+ return # footer is optional and there's nothing to parse
entries = stem.descriptor._get_descriptor_components(content, validate)
self._parse(entries, validate, header)
@@ -773,7 +773,7 @@ class _DocumentFooter(object):
raise ValueError("Authority signatures in a network status document are expected to be of the form 'directory-signature [METHOD] FINGERPRINT KEY_DIGEST\\nSIGNATURE', got:\n%s\n%s" % (sig_value, block_contents))
if sig_value.count(" ") == 1:
- method = 'sha1' # default if none was provided
+ method = 'sha1' # default if none was provided
fingerprint, key_digest = sig_value.split(" ", 1)
else:
method, fingerprint, key_digest = sig_value.split(" ", 2)
diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index 6069bfa..d47a5ed 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -173,7 +173,7 @@ def load_processed_files(path):
for line in input_file.readlines():
line = line.strip()
- if not line: continue # skip blank lines
+ if not line: continue # skip blank lines
if not " " in line:
raise TypeError("Malformed line: %s" % line)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index da9715d..1ea13a2 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -126,7 +126,7 @@ def parse_file(descriptor_file, validate = True):
descriptor_text = "".join(descriptor_content)
yield RelayDescriptor(descriptor_text, validate, annotations)
- else: break # done parsing descriptors
+ else: break # done parsing descriptors
class ServerDescriptor(stem.descriptor.Descriptor):
"""
@@ -242,7 +242,7 @@ class ServerDescriptor(stem.descriptor.Descriptor):
self._unrecognized_lines = []
self._annotation_lines = annotations if annotations else []
- self._annotation_dict = None # cached breakdown of key/value mappings
+ self._annotation_dict = None # cached breakdown of key/value mappings
# A descriptor contains a series of 'keyword lines' which are simply a
# keyword followed by an optional value. Lines can also be followed by a
@@ -325,7 +325,7 @@ class ServerDescriptor(stem.descriptor.Descriptor):
# most just work with the first (and only) value
value, block_contents = values[0]
- line = "%s %s" % (keyword, value) # original line
+ line = "%s %s" % (keyword, value) # original line
if block_contents: line += "\n%s" % block_contents
if keyword == "router":
@@ -490,7 +490,7 @@ class ServerDescriptor(stem.descriptor.Descriptor):
div = entry.rfind(":")
address, ports = entry[:div], entry[div + 1:]
is_ipv6 = address.startswith("[") and address.endswith("]")
- if is_ipv6: address = address[1:-1] # remove brackets
+ if is_ipv6: address = address[1:-1] # remove brackets
if not ((not is_ipv6 and stem.util.connection.is_valid_ip_address(address)) or
(is_ipv6 and stem.util.connection.is_valid_ipv6_address(address))):
@@ -669,7 +669,7 @@ class RelayDescriptor(ServerDescriptor):
seq = asn1.DerSequence()
seq.decode(key_as_der)
modulus = seq[0]
- public_exponent = seq[1] # should always be 65537
+ public_exponent = seq[1] # should always be 65537
sig_as_bytes = RelayDescriptor._get_key_bytes(self.signature)
@@ -727,7 +727,7 @@ class RelayDescriptor(ServerDescriptor):
raise ValueError("Decrypted digest does not match local digest")
def _parse(self, entries, validate):
- entries = dict(entries) # shallow copy since we're destructive
+ entries = dict(entries) # shallow copy since we're destructive
# handles fields only in server descriptors
diff --git a/stem/exit_policy.py b/stem/exit_policy.py
index eb34e97..9b0a111 100644
--- a/stem/exit_policy.py
+++ b/stem/exit_policy.py
@@ -188,7 +188,7 @@ class ExitPolicy(object):
if display_ports:
display_ranges, temp_range = [], []
display_ports.sort()
- display_ports.append(None) # ending item to include last range in loop
+ display_ports.append(None) # ending item to include last range in loop
for port in display_ports:
if not temp_range or temp_range[-1] + 1 == port:
@@ -702,7 +702,7 @@ class MicroExitPolicyRule(ExitPolicyRule):
def __init__(self, is_accept, min_port, max_port):
self.is_accept = is_accept
- self.address = None # wildcard address
+ self.address = None # wildcard address
self.min_port = min_port
self.max_port = max_port
self._str_representation = None
diff --git a/stem/process.py b/stem/process.py
index 6698c99..4db51d3 100644
--- a/stem/process.py
+++ b/stem/process.py
@@ -126,7 +126,7 @@ def launch_tor(tor_cmd = "tor", args = None, torrc_path = None, completion_perce
# this will provide empty results if the process is terminated
if not init_line:
- if timeout: signal.alarm(0) # stop alarm
+ if timeout: signal.alarm(0) # stop alarm
# ... but best make sure
if stem.prereq.is_python_26():
@@ -144,7 +144,7 @@ def launch_tor(tor_cmd = "tor", args = None, torrc_path = None, completion_perce
problem_match = problem_line.search(init_line)
if bootstrap_match and int(bootstrap_match.groups()[0]) >= completion_percent:
- if timeout: signal.alarm(0) # stop alarm
+ if timeout: signal.alarm(0) # stop alarm
if temp_file:
try: os.remove(temp_file)
diff --git a/stem/response/__init__.py b/stem/response/__init__.py
index 1b7387b..388d755 100644
--- a/stem/response/__init__.py
+++ b/stem/response/__init__.py
@@ -285,7 +285,7 @@ class ControlLine(str):
**False** otherwise
"""
- remainder = self._remainder # temp copy to avoid locking
+ remainder = self._remainder # temp copy to avoid locking
key_match = KEY_ARG.match(remainder)
if key_match:
@@ -297,9 +297,9 @@ class ControlLine(str):
start_quote, end_quote = _get_quote_indices(remainder, escaped)
return start_quote == key_match.end() and end_quote != -1
else:
- return True # we just needed to check for the key
+ return True # we just needed to check for the key
else:
- return False # doesn't start with a key
+ return False # doesn't start with a key
def peek_key(self):
"""
diff --git a/stem/response/getconf.py b/stem/response/getconf.py
index 6e96c83..bf16ec1 100644
--- a/stem/response/getconf.py
+++ b/stem/response/getconf.py
@@ -39,7 +39,7 @@ class GetConfResponse(stem.response.ControlMessage):
line = remaining_lines.pop(0)
if line.is_next_mapping(quoted = False):
- key, value = line.split("=", 1) # TODO: make this part of the ControlLine?
+ key, value = line.split("=", 1) # TODO: make this part of the ControlLine?
elif line.is_next_mapping(quoted = True):
# TODO: doesn't seem to occur yet in practice...
# https://trac.torproject.org/6172
diff --git a/stem/socket.py b/stem/socket.py
index 2055991..4dca361 100644
--- a/stem/socket.py
+++ b/stem/socket.py
@@ -183,7 +183,7 @@ class ControlSocket(object):
try:
self._connect()
except stem.SocketError:
- self._connect() # single retry
+ self._connect() # single retry
def close(self):
"""
@@ -482,7 +482,7 @@ def recv_message(control_file):
log.info(prefix + "no CRLF linebreak, \"%s\"" % log.escape(line))
raise stem.ProtocolError("All lines should end with CRLF")
- line = line[:-2] # strips off the CRLF
+ line = line[:-2] # strips off the CRLF
status_code, divider, content = line[:3], line[3], line[4:]
if divider == "-":
@@ -514,9 +514,9 @@ def recv_message(control_file):
log.info(prefix + "CRLF linebreaks missing from a data reply, \"%s\"" % log.escape(raw_content))
raise stem.ProtocolError("All lines should end with CRLF")
elif line == ".\r\n":
- break # data block termination
+ break # data block termination
- line = line[:-2] # strips off the CRLF
+ line = line[:-2] # strips off the CRLF
# lines starting with a period are escaped by a second period (as per
# section 2.4 of the control-spec)
diff --git a/stem/util/conf.py b/stem/util/conf.py
index 05d3796..0166ad9 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -169,7 +169,7 @@ class _SyncListener(object):
def update(self, config, key):
if key in self.config_dict:
new_value = config.get(key, self.config_dict[key])
- if new_value == self.config_dict[key]: return # no change
+ if new_value == self.config_dict[key]: return # no change
if self.interceptor:
interceptor_value = self.interceptor(key, new_value)
@@ -268,7 +268,7 @@ def parse_enum_csv(key, value, enumeration, count = None):
if values == ['']: return []
if count is None:
- pass # no count validateion checks to do
+ pass # no count validateion checks to do
elif isinstance(count, int):
if len(values) != count:
raise ValueError("Config entry '%s' is expected to be %i comma separated values, got '%s'" % (key, count, value))
@@ -432,8 +432,8 @@ class Config(object):
multiline_buffer = []
while remainder and remainder[0].lstrip().startswith("|"):
- content = remainder.pop(0).lstrip()[1:] # removes '\s+|' prefix
- content = content.rstrip("\n") # trailing newline
+ content = remainder.pop(0).lstrip()[1:] # removes '\s+|' prefix
+ content = content.rstrip("\n") # trailing newline
multiline_buffer.append(content)
if multiline_buffer:
@@ -588,7 +588,7 @@ class Config(object):
is_multivalue = isinstance(default, (list, tuple, dict))
val = self.get_value(key, default, is_multivalue)
- if val == default: return val # don't try to infer undefined values
+ if val == default: return val # don't try to infer undefined values
if isinstance(default, bool):
if val.lower() == "true": val = True
@@ -607,7 +607,7 @@ class Config(object):
log.debug("Config entry '%s' is expected to be a float, defaulting to '%f'" % (key, default))
val = default
elif isinstance(default, list):
- pass # nothing special to do (already a list)
+ pass # nothing special to do (already a list)
elif isinstance(default, tuple):
val = tuple(val)
elif isinstance(default, dict):
diff --git a/stem/util/connection.py b/stem/util/connection.py
index 8eefea2..3b16c1f 100644
--- a/stem/util/connection.py
+++ b/stem/util/connection.py
@@ -49,7 +49,7 @@ def is_valid_ip_address(address):
if not entry.isdigit() or int(entry) < 0 or int(entry) > 255:
return False
elif entry[0] == "0" and len(entry) > 1:
- return False # leading zeros, for instance in "1.2.3.001"
+ return False # leading zeros, for instance in "1.2.3.001"
return True
@@ -74,11 +74,11 @@ def is_valid_ipv6_address(address, allow_brackets = False):
colon_count = address.count(":")
if colon_count > 7:
- return False # too many groups
+ return False # too many groups
elif colon_count != 7 and not "::" in address:
- return False # not enough groups and none are collapsed
+ return False # not enough groups and none are collapsed
elif address.count("::") > 1 or ":::" in address:
- return False # multiple groupings of zeros can't be collapsed
+ return False # multiple groupings of zeros can't be collapsed
for entry in address.split(":"):
if not re.match("^[0-9a-fA-f]{0,4}$", entry):
@@ -106,7 +106,7 @@ def is_valid_port(entry, allow_zero = False):
if not entry.isdigit():
return False
elif entry[0] == "0" and len(entry) > 1:
- return False # leading zeros, ex "001"
+ return False # leading zeros, ex "001"
entry = int(entry)
diff --git a/stem/util/proc.py b/stem/util/proc.py
index bfb771e..05a7ff0 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -317,7 +317,7 @@ def get_connections(pid):
for proc_file_path in ("/proc/net/tcp", "/proc/net/udp"):
try:
proc_file = open(proc_file_path)
- proc_file.readline() # skip the first line
+ proc_file.readline() # skip the first line
for line in proc_file:
_, l_addr, f_addr, status, _, _, _, _, _, inode = line.split()[:10]
@@ -411,7 +411,7 @@ def _get_lines(file_path, line_prefixes, parameter):
proc_file, results = open(file_path), {}
for line in proc_file:
- if not remaining_prefixes: break # found everything we're looking for
+ if not remaining_prefixes: break # found everything we're looking for
for prefix in remaining_prefixes:
if line.startswith(prefix):
diff --git a/stem/util/system.py b/stem/util/system.py
index 9e7aaa2..a3a4c5f 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -322,7 +322,7 @@ def get_pid_by_port(port):
results = [r for r in results if "127.0.0.1:%s" % port in r]
if len(results) == 1 and len(results[0].split()) == 7:
- results = results[0].split()[6] # process field (ex. "7184/tor")
+ results = results[0].split()[6] # process field (ex. "7184/tor")
pid = results[:results.find("/")]
if pid.isdigit(): return int(pid)
@@ -390,7 +390,7 @@ def get_pid_by_port(port):
pid = results[0].split()[1]
if pid.isdigit(): return int(pid)
- return None # all queries failed
+ return None # all queries failed
def get_pid_by_open_file(path):
"""
@@ -425,7 +425,7 @@ def get_pid_by_open_file(path):
pid = results[0].strip()
if pid.isdigit(): return int(pid)
- return None # all queries failed
+ return None # all queries failed
def get_cwd(pid):
"""
@@ -489,7 +489,7 @@ def get_cwd(pid):
else:
log.debug("%s we got unexpected output from lsof: %s" % (logging_prefix, results))
- return None # all queries failed
+ return None # all queries failed
def get_bsd_jail_id(pid):
"""
diff --git a/stem/version.py b/stem/version.py
index 43c96ba..bf8c32c 100644
--- a/stem/version.py
+++ b/stem/version.py
@@ -172,7 +172,7 @@ class Version(object):
"""
if not isinstance(other, Version):
- return 1 # this is also used for equality checks
+ return 1 # this is also used for equality checks
for attr in ("major", "minor", "micro", "patch"):
my_version = max(0, self.__dict__[attr])
diff --git a/test/check_whitespace.py b/test/check_whitespace.py
index bda512e..ba41190 100644
--- a/test/check_whitespace.py
+++ b/test/check_whitespace.py
@@ -54,7 +54,7 @@ def pep8_issues(base_path = DEFAULT_TARGET):
# Pep8 only works with this one if we have four space indents (its
# detection is based on multiples of four).
- ignored_issues = "E111,E121,W293,E501,E302,E701,E251,E261,E127"
+ ignored_issues = "E111,E121,W293,E501,E302,E701,E251,E127"
issues = {}
pep8_output = system.call("pep8 --ignore %s %s" % (ignored_issues, base_path))
diff --git a/test/integ/control/base_controller.py b/test/integ/control/base_controller.py
index a2814ce..d43b009 100644
--- a/test/integ/control/base_controller.py
+++ b/test/integ/control/base_controller.py
@@ -246,7 +246,7 @@ class TestBaseController(unittest.TestCase):
controller.add_status_listener(state_observer.listener, True)
controller.close()
- time.sleep(0.1) # not much work going on so this doesn't need to be much
+ time.sleep(0.1) # not much work going on so this doesn't need to be much
self.assertEquals(controller, state_observer.controller)
self.assertEquals(stem.control.State.CLOSED, state_observer.state)
self.assertTrue(state_observer.timestamp < time.time())
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 901a0e1..b769fbc 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -658,7 +658,7 @@ class TestController(unittest.TestCase):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', int(controller.get_conf('SocksListenAddress').rsplit(':', 1)[1])))
test.util.negotiate_socks(s, '1.2.1.2', 80)
- s.sendall(test.util.ip_request) # make the http request for the ip address
+ s.sendall(test.util.ip_request) # make the http request for the ip address
response = s.recv(1000)
# everything after the blank line is the 'data' in a HTTP response.
diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py
index 06b1a3c..a2bf144 100644
--- a/test/integ/descriptor/extrainfo_descriptor.py
+++ b/test/integ/descriptor/extrainfo_descriptor.py
@@ -23,7 +23,7 @@ class TestExtraInfoDescriptor(unittest.TestCase):
descriptor_path = test.integ.descriptor.get_resource("extrainfo_relay_descriptor")
descriptor_file = open(descriptor_path)
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_contents = descriptor_file.read()
descriptor_file.close()
@@ -74,7 +74,7 @@ k0d2aofcVbHr4fPQOSST0LXDrhFl5Fqo5um296zpJGvRUeO6S44U/EfJAGShtqWw
descriptor_path = test.integ.descriptor.get_resource("extrainfo_bridge_descriptor")
descriptor_file = open(descriptor_path)
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_contents = descriptor_file.read()
descriptor_file.close()
diff --git a/test/integ/descriptor/networkstatus.py b/test/integ/descriptor/networkstatus.py
index d6ef4fc..ad2933e 100644
--- a/test/integ/descriptor/networkstatus.py
+++ b/test/integ/descriptor/networkstatus.py
@@ -234,7 +234,7 @@ TpQQk3nNQF8z6UIvdlvP+DnJV4izWVkQEZgUZgIVM0E=
consensus_path = test.integ.descriptor.get_resource("cached-consensus-v2")
with open(consensus_path) as descriptor_file:
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
document = stem.descriptor.networkstatus.NetworkStatusDocumentV2(descriptor_file.read())
self.assertEquals(2, document.version)
diff --git a/test/integ/descriptor/reader.py b/test/integ/descriptor/reader.py
index a285952..637583e 100644
--- a/test/integ/descriptor/reader.py
+++ b/test/integ/descriptor/reader.py
@@ -60,7 +60,7 @@ def _get_raw_tar_descriptors():
for tar_entry in tar_file:
if tar_entry.isfile():
entry = tar_file.extractfile(tar_entry)
- entry.readline() # strip header
+ entry.readline() # strip header
raw_descriptors.append(entry.read())
entry.close()
finally:
@@ -72,7 +72,7 @@ def _get_raw_tar_descriptors():
class SkipListener:
def __init__(self):
- self.results = [] # (path, exception) tuples that we've received
+ self.results = [] # (path, exception) tuples that we've received
def listener(self, path, exception):
self.results.append((path, exception))
@@ -122,7 +122,7 @@ class TestDescriptorReader(unittest.TestCase):
test.runner.skip(self, "(chmod not functional)")
test_listing_path = _make_processed_files_listing(BASIC_LISTING)
- os.chmod(test_listing_path, 0077) # remove read permissions
+ os.chmod(test_listing_path, 0077) # remove read permissions
self.assertRaises(IOError, stem.descriptor.reader.load_processed_files, test_listing_path)
def test_save_processed_files(self):
@@ -168,7 +168,7 @@ class TestDescriptorReader(unittest.TestCase):
descriptor_path = os.path.join(DESCRIPTOR_TEST_DATA, "example_descriptor")
with open(descriptor_path) as descriptor_file:
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_entries.append(descriptor_file.read())
# running this test multiple times to flush out concurrency issues
@@ -335,7 +335,7 @@ class TestDescriptorReader(unittest.TestCase):
expected_results[path] = last_modified
reader = stem.descriptor.reader.DescriptorReader(DESCRIPTOR_TEST_DATA)
- with reader: list(reader) # iterates over all of the descriptors
+ with reader: list(reader) # iterates over all of the descriptors
self.assertEquals(expected_results, reader.get_processed_files())
@@ -349,12 +349,12 @@ class TestDescriptorReader(unittest.TestCase):
reader = stem.descriptor.reader.DescriptorReader(DESCRIPTOR_TEST_DATA)
reader.register_skip_listener(skip_listener.listener)
- with reader: list(reader) # iterates over all of the descriptors
+ with reader: list(reader) # iterates over all of the descriptors
self.assertEqual(4, len(skip_listener.results))
for skip_path, skip_exception in skip_listener.results:
- if skip_path.endswith(".swp"): continue # skip vim temp files
+ if skip_path.endswith(".swp"): continue # skip vim temp files
if not os.path.basename(skip_path) in ("riddle", "tiny.png", "vote", "new_metrics_type"):
self.fail("Unexpected non-descriptor content: %s" % skip_path)
@@ -378,7 +378,7 @@ class TestDescriptorReader(unittest.TestCase):
reader.set_processed_files(initial_processed_files)
self.assertEquals(initial_processed_files, reader.get_processed_files())
- with reader: list(reader) # iterates over all of the descriptors
+ with reader: list(reader) # iterates over all of the descriptors
self.assertEquals(1, len(skip_listener.results))
@@ -405,7 +405,7 @@ class TestDescriptorReader(unittest.TestCase):
skip_listener = SkipListener()
reader = stem.descriptor.reader.DescriptorReader(test_path)
reader.register_skip_listener(skip_listener.listener)
- with reader: list(reader) # iterates over all of the descriptors
+ with reader: list(reader) # iterates over all of the descriptors
self.assertEqual(1, len(skip_listener.results))
@@ -432,12 +432,12 @@ class TestDescriptorReader(unittest.TestCase):
test_file.write("test data for test_skip_listener_unrecognized_type()")
test_file.close()
- os.chmod(test_path, 0077) # remove read permissions
+ os.chmod(test_path, 0077) # remove read permissions
skip_listener = SkipListener()
reader = stem.descriptor.reader.DescriptorReader(test_path)
reader.register_skip_listener(skip_listener.listener)
- with reader: list(reader) # iterates over all of the descriptors
+ with reader: list(reader) # iterates over all of the descriptors
self.assertEqual(1, len(skip_listener.results))
@@ -459,7 +459,7 @@ class TestDescriptorReader(unittest.TestCase):
skip_listener = SkipListener()
reader = stem.descriptor.reader.DescriptorReader(test_path)
reader.register_skip_listener(skip_listener.listener)
- with reader: list(reader) # iterates over all of the descriptors
+ with reader: list(reader) # iterates over all of the descriptors
self.assertEqual(1, len(skip_listener.results))
@@ -477,7 +477,7 @@ class TestDescriptorReader(unittest.TestCase):
skip_listener = SkipListener()
reader = stem.descriptor.reader.DescriptorReader(test_path)
reader.register_skip_listener(skip_listener.listener)
- with reader: list(reader) # iterates over all of the descriptors
+ with reader: list(reader) # iterates over all of the descriptors
self.assertEqual(1, len(skip_listener.results))
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index ae30209..a2ee34a 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -24,7 +24,7 @@ class TestServerDescriptor(unittest.TestCase):
descriptor_path = test.integ.descriptor.get_resource("example_descriptor")
descriptor_file = open(descriptor_path)
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_contents = descriptor_file.read()
descriptor_file.close()
@@ -96,7 +96,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
descriptor_path = test.integ.descriptor.get_resource("old_descriptor")
descriptor_file = open(descriptor_path)
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_contents = descriptor_file.read()
descriptor_file.close()
@@ -182,7 +182,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
descriptor_path = test.integ.descriptor.get_resource("non-ascii_descriptor")
descriptor_file = open(descriptor_path)
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_contents = descriptor_file.read()
descriptor_file.close()
@@ -224,7 +224,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
descriptor_path = test.integ.descriptor.get_resource("cr_in_contact_line")
descriptor_file = open(descriptor_path)
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_contents = descriptor_file.read()
descriptor_file.close()
@@ -252,7 +252,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
descriptor_path = test.integ.descriptor.get_resource("negative_uptime")
descriptor_file = open(descriptor_path)
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_contents = descriptor_file.read()
descriptor_file.close()
@@ -276,7 +276,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
descriptor_path = test.integ.descriptor.get_resource("bridge_descriptor")
descriptor_file = open(descriptor_path)
- descriptor_file.readline() # strip header
+ descriptor_file.readline() # strip header
descriptor_contents = descriptor_file.read()
descriptor_file.close()
diff --git a/test/integ/process.py b/test/integ/process.py
index 7aa3382..ea8909a 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -26,7 +26,7 @@ def _kill_process(process):
elif not stem.util.system.is_windows():
os.kill(process.pid, signal.SIGTERM)
- process.communicate() # block until its definitely gone
+ process.communicate() # block until its definitely gone
class TestProcess(unittest.TestCase):
def setUp(self):
@@ -136,7 +136,7 @@ class TestProcess(unittest.TestCase):
for seconds_waited in xrange(30):
if tor_process.poll() == 0:
- return # tor exited
+ return # tor exited
time.sleep(1)
@@ -171,7 +171,7 @@ class TestProcess(unittest.TestCase):
# give tor a few seconds to quit
for seconds_waited in xrange(5):
if tor_process.poll() == 0:
- return # tor exited
+ return # tor exited
time.sleep(1)
diff --git a/test/mocking.py b/test/mocking.py
index 12c6bef..ff314ee 100644
--- a/test/mocking.py
+++ b/test/mocking.py
@@ -459,7 +459,7 @@ def get_object(object_class, methods = None):
if method_name in methods:
mock_methods[method_name] = methods[method_name]
elif method_name.startswith('__') and method_name.endswith('__'):
- pass # messing with most private methods makes for a broken mock object
+ pass # messing with most private methods makes for a broken mock object
else:
mock_methods[method_name] = raise_exception(ValueError("Unexpected call of '%s' on a mock object" % method_name))
@@ -548,7 +548,7 @@ def _get_descriptor_content(attr = None, exclude = (), header_template = (), foo
header_content, footer_content = [], []
if attr is None: attr = {}
- attr = dict(attr) # shallow copy since we're destructive
+ attr = dict(attr) # shallow copy since we're destructive
for content, template in ((header_content, header_template),
(footer_content, footer_template)):
@@ -863,7 +863,7 @@ def sign_descriptor_content(desc_content):
# generate the new signing key string
- signing_key_token = "\nsigning-key\n" # note the trailing '\n' is important here so as not to match the string elsewhere
+ signing_key_token = "\nsigning-key\n" # note the trailing '\n' is important here so as not to match the string elsewhere
signing_key_token_start = "-----BEGIN RSA PUBLIC KEY-----\n"
signing_key_token_end = "\n-----END RSA PUBLIC KEY-----\n"
new_sk = signing_key_token + signing_key_token_start + public_key_string + signing_key_token_end
diff --git a/test/runner.py b/test/runner.py
index 17abefb..af5ed73 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -332,7 +332,7 @@ class Runner(object):
test.output.print_line("failed (unable to call kill() in python 2.5)", *ERROR_ATTR)
except OSError: pass
- self._tor_process.communicate() # blocks until the process is done
+ self._tor_process.communicate() # blocks until the process is done
# if we've made a temporary data directory then clean it up
if self._test_dir and CONFIG["integ.test_directory"] == "":
diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py
index aa2c7ae..34b98a5 100644
--- a/test/unit/control/controller.py
+++ b/test/unit/control/controller.py
@@ -153,10 +153,10 @@ class TestControl(unittest.TestCase):
# check where GETINFO provides malformed content
invalid_responses = (
- '"127.0.0.1"', # address only
- '"1112"', # port only
- '"5127.0.0.1:1112"', # invlaid address
- '"127.0.0.1:991112"', # invalid port
+ '"127.0.0.1"', # address only
+ '"1112"', # port only
+ '"5127.0.0.1:1112"', # invlaid address
+ '"127.0.0.1:991112"', # invalid port
)
for response in invalid_responses:
@@ -301,12 +301,12 @@ class TestControl(unittest.TestCase):
# exercise with some invalid inputs
malformed_inputs = [
- '=piyaz', # no fingerprint
- '999A226EBED397F331B612FE1E4CFAE5C1F201BA=piyaz', # fingerprint missing prefix
- '$999A226EBED397F331B612FE1E4CFAE5C1F201BAA=piyaz', # fingerprint too long
- '$999A226EBED397F331B612FE1E4CFAE5C1F201B=piyaz', # fingerprint too short
- '$999A226EBED397F331B612FE1E4CFAE5C1F201Bz=piyaz', # invalid character in fingerprint
- '$999A226EBED397F331B612FE1E4CFAE5C1F201BA=', # no nickname
+ '=piyaz', # no fingerprint
+ '999A226EBED397F331B612FE1E4CFAE5C1F201BA=piyaz', # fingerprint missing prefix
+ '$999A226EBED397F331B612FE1E4CFAE5C1F201BAA=piyaz', # fingerprint too long
+ '$999A226EBED397F331B612FE1E4CFAE5C1F201B=piyaz', # fingerprint too short
+ '$999A226EBED397F331B612FE1E4CFAE5C1F201Bz=piyaz', # invalid character in fingerprint
+ '$999A226EBED397F331B612FE1E4CFAE5C1F201BA=', # no nickname
]
for test_input in malformed_inputs:
diff --git a/test/unit/descriptor/networkstatus/document_v3.py b/test/unit/descriptor/networkstatus/document_v3.py
index f422f5b..0ab5694 100644
--- a/test/unit/descriptor/networkstatus/document_v3.py
+++ b/test/unit/descriptor/networkstatus/document_v3.py
@@ -163,7 +163,7 @@ class TestNetworkStatusDocument(unittest.TestCase):
if is_mandatory and ((is_consensus and in_consensus) or (is_vote and in_votes)):
content = get_network_status_document_v3(attr, exclude = (field,), content = True)
self.assertRaises(ValueError, NetworkStatusDocumentV3, content)
- NetworkStatusDocumentV3(content, False) # constructs without validation
+ NetworkStatusDocumentV3(content, False) # constructs without validation
def test_unrecognized_line(self):
"""
@@ -193,7 +193,7 @@ class TestNetworkStatusDocument(unittest.TestCase):
content = "\n".join(test_lines)
self.assertRaises(ValueError, NetworkStatusDocumentV3, content)
- NetworkStatusDocumentV3(content, False) # constructs without validation
+ NetworkStatusDocumentV3(content, False) # constructs without validation
def test_duplicate_fields(self):
"""
@@ -220,7 +220,7 @@ class TestNetworkStatusDocument(unittest.TestCase):
content = "\n".join(test_lines)
self.assertRaises(ValueError, NetworkStatusDocumentV3, content)
- NetworkStatusDocumentV3(content, False) # constructs without validation
+ NetworkStatusDocumentV3(content, False) # constructs without validation
def test_version(self):
"""
@@ -293,7 +293,7 @@ class TestNetworkStatusDocument(unittest.TestCase):
(" ", []),
("1 2 3 a 5", [1, 2, 3, 5]),
("1 2 3 4.0 5", [1, 2, 3, 5]),
- ("2 3 4", [2, 3, 4]), # spec says version one must be included
+ ("2 3 4", [2, 3, 4]), # spec says version one must be included
)
for test_value, expected_consensus_methods in test_values:
@@ -693,7 +693,7 @@ class TestNetworkStatusDocument(unittest.TestCase):
content = get_network_status_document_v3({"directory-signature": "%s %s\n%s" % tuple(attrs)}, content = True)
self.assertRaises(ValueError, NetworkStatusDocumentV3, content)
- NetworkStatusDocumentV3(content, False) # checks that it's still parsable without validation
+ NetworkStatusDocumentV3(content, False) # checks that it's still parsable without validation
def test_with_router_status_entries(self):
"""
diff --git a/test/unit/descriptor/router_status_entry.py b/test/unit/descriptor/router_status_entry.py
index a0ff74d..5d74678 100644
--- a/test/unit/descriptor/router_status_entry.py
+++ b/test/unit/descriptor/router_status_entry.py
@@ -190,8 +190,8 @@ class TestRouterStatusEntry(unittest.TestCase):
test_values = (
"",
- "saberrider2008ReallyLongNickname", # too long
- "$aberrider2008", # invalid characters
+ "saberrider2008ReallyLongNickname", # too long
+ "$aberrider2008", # invalid characters
)
for value in test_values:
@@ -474,7 +474,7 @@ class TestRouterStatusEntry(unittest.TestCase):
}
# we need a document that's a vote
- mock_document = lambda x: x # just need anything with a __dict__
+ mock_document = lambda x: x # just need anything with a __dict__
mock_document.__dict__["is_vote"] = True
mock_document.__dict__["is_consensus"] = False
diff --git a/test/unit/response/control_message.py b/test/unit/response/control_message.py
index 091aff9..4a55c98 100644
--- a/test/unit/response/control_message.py
+++ b/test/unit/response/control_message.py
@@ -170,7 +170,7 @@ class TestControlMessage(unittest.TestCase):
# checks that the contents match the input
message_lines = str(message).splitlines()
controller_lines = controller_reply.split("\r\n")
- controller_lines.pop() # the ControlMessage won't have a trailing newline
+ controller_lines.pop() # the ControlMessage won't have a trailing newline
while controller_lines:
line = controller_lines.pop(0)
diff --git a/test/unit/response/events.py b/test/unit/response/events.py
index 885be6b..adc055c 100644
--- a/test/unit/response/events.py
+++ b/test/unit/response/events.py
@@ -10,7 +10,7 @@ import stem.response
import stem.response.events
import stem.util.log
-from stem import * # enums and exceptions
+from stem import * # enums and exceptions
from test import mocking
# ADDRMAP event
diff --git a/test/unit/tutorial.py b/test/unit/tutorial.py
index 6358344..47e8107 100644
--- a/test/unit/tutorial.py
+++ b/test/unit/tutorial.py
@@ -51,7 +51,7 @@ class TestTutorial(unittest.TestCase):
'__exit__': mocking.no_op(),
'__iter__': mocking.return_value(iter((
exit_descriptor,
- mocking.get_relay_server_descriptor(), # non-exit
+ mocking.get_relay_server_descriptor(), # non-exit
exit_descriptor,
exit_descriptor,
)))
diff --git a/test/unit/util/conf.py b/test/unit/util/conf.py
index abb645a..4e70c1d 100644
--- a/test/unit/util/conf.py
+++ b/test/unit/util/conf.py
@@ -118,7 +118,7 @@ class TestConf(unittest.TestCase):
self.assertRaises(ValueError, parse_enum_csv, "my_option", "ugabuga", Insects)
self.assertRaises(ValueError, parse_enum_csv, "my_option", "ladybug, ugabuga", Insects)
- self.assertRaises(ValueError, parse_enum_csv, "my_option", "ladybug butterfly", Insects) # no comma
+ self.assertRaises(ValueError, parse_enum_csv, "my_option", "ladybug butterfly", Insects) # no comma
self.assertRaises(ValueError, parse_enum_csv, "my_option", "ladybug", Insects, 2)
self.assertRaises(ValueError, parse_enum_csv, "my_option", "ladybug", Insects, (2, 3))
diff --git a/test/unit/util/str_tools.py b/test/unit/util/str_tools.py
index ed31c43..c1c5ee8 100644
--- a/test/unit/util/str_tools.py
+++ b/test/unit/util/str_tools.py
@@ -143,8 +143,8 @@ class TestStrTools(unittest.TestCase):
None,
32,
'hello world',
- '2012-11-08T16:48:41.42025', # too few microsecond digits
- '2012-11-08T16:48:41.4202511', # too many microsecond digits
+ '2012-11-08T16:48:41.42025', # too few microsecond digits
+ '2012-11-08T16:48:41.4202511', # too many microsecond digits
'2012-11-08T16:48',
]
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits