[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Reordering import statements



commit 3da47d3b9d6d1ae5c6b2013a4247c45c13461a05
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Dec 8 22:02:29 2012 -0800

    Reordering import statements
    
    Dropping my oddball import ordering scheme in favor of the python standard.
    Now that we're getting more contributors making the library newcomer-friendly
    defintely trumps my weird notions of aesthetically pleasant imports.
    
    Taking this opportunity to also drop use of the 'as' import keyword. I'm still
    a little unsure what the most 'proper' style for imports is, but I've defintely
    seen 'from' used a lot more than 'as'.
---
 run_tests.py                                       |   51 ++++++++++----------
 stem/connection.py                                 |   13 +++--
 stem/control.py                                    |   11 ++--
 stem/descriptor/__init__.py                        |    1 +
 stem/descriptor/export.py                          |    2 +-
 stem/descriptor/extrainfo_descriptor.py            |    6 +-
 stem/descriptor/networkstatus.py                   |    2 +-
 stem/descriptor/reader.py                          |    6 +-
 stem/descriptor/server_descriptor.py               |   11 ++--
 stem/prereq.py                                     |    2 +-
 stem/process.py                                    |    4 +-
 stem/response/authchallenge.py                     |    2 +-
 stem/response/events.py                            |    4 +-
 stem/response/getconf.py                           |    2 +-
 stem/response/getinfo.py                           |    2 +-
 stem/response/mapaddress.py                        |    2 +-
 stem/response/protocolinfo.py                      |    4 +-
 stem/socket.py                                     |    3 +-
 stem/util/conf.py                                  |    2 +-
 stem/util/connection.py                            |    4 +-
 stem/util/proc.py                                  |    9 ++--
 stem/util/system.py                                |    5 +-
 test/integ/connection/authentication.py            |   15 +++---
 test/integ/connection/connect.py                   |    2 +-
 test/integ/control/base_controller.py              |    4 +-
 test/integ/control/controller.py                   |   10 ++--
 test/integ/descriptor/extrainfo_descriptor.py      |    5 +-
 test/integ/descriptor/networkstatus.py             |    4 +-
 test/integ/descriptor/reader.py                    |    7 ++-
 test/integ/descriptor/server_descriptor.py         |    6 +-
 test/integ/process.py                              |   10 ++--
 test/integ/response/protocolinfo.py                |    9 ++--
 test/integ/util/proc.py                            |    3 +-
 test/integ/util/system.py                          |    7 ++-
 test/integ/version.py                              |    2 +-
 test/mocking.py                                    |    6 +-
 test/output.py                                     |    3 +-
 test/prompt.py                                     |    2 +-
 test/runner.py                                     |   13 +++--
 test/unit/connection/authentication.py             |    5 +-
 test/unit/descriptor/extrainfo_descriptor.py       |    1 +
 test/unit/descriptor/networkstatus/document_v3.py  |   26 ++++++++--
 .../descriptor/networkstatus/key_certificate.py    |    6 ++-
 test/unit/descriptor/reader.py                     |    2 +-
 test/unit/descriptor/router_status_entry.py        |    8 ++-
 test/unit/descriptor/server_descriptor.py          |    9 +++-
 test/unit/exit_policy/policy.py                    |    1 +
 test/unit/response/authchallenge.py                |    5 +-
 test/unit/response/control_line.py                 |    1 +
 test/unit/response/control_message.py              |    1 +
 test/unit/response/events.py                       |    2 +-
 test/unit/response/getconf.py                      |    5 +-
 test/unit/response/getinfo.py                      |    5 +-
 test/unit/response/mapaddress.py                   |    5 +-
 test/unit/response/protocolinfo.py                 |    9 ++--
 test/unit/response/singleline.py                   |    5 +-
 test/unit/tutorial.py                              |    3 +-
 test/unit/util/conf.py                             |    1 +
 test/unit/util/connection.py                       |    1 +
 test/unit/util/enum.py                             |    1 +
 test/unit/util/proc.py                             |    6 +-
 test/unit/util/system.py                           |   12 +++--
 test/unit/util/tor_tools.py                        |    1 +
 test/unit/version.py                               |    7 ++-
 test/util.py                                       |    5 +-
 65 files changed, 226 insertions(+), 163 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index cbf08d6..d57765b 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -4,37 +4,46 @@
 Runs unit and integration tests. For usage information run this with '--help'.
 """
 
+import getopt
 import os
+import StringIO
 import sys
+import threading
 import time
-import getopt
 import unittest
-import threading
-import StringIO
 
+import stem.prereq
+import stem.util.conf
+import stem.util.enum
+
+from stem.util import log, system, term
+
+import test.check_whitespace
 import test.output
 import test.runner
-import test.check_whitespace
 import test.unit.connection.authentication
 import test.unit.control.controller
 import test.unit.descriptor.export
-import test.unit.descriptor.reader
-import test.unit.descriptor.server_descriptor
 import test.unit.descriptor.extrainfo_descriptor
-import test.unit.descriptor.router_status_entry
 import test.unit.descriptor.networkstatus.directory_authority
-import test.unit.descriptor.networkstatus.key_certificate
 import test.unit.descriptor.networkstatus.document_v2
 import test.unit.descriptor.networkstatus.document_v3
+import test.unit.descriptor.networkstatus.key_certificate
+import test.unit.descriptor.reader
+import test.unit.descriptor.router_status_entry
+import test.unit.descriptor.server_descriptor
+import test.unit.exit_policy.policy
+import test.unit.exit_policy.rule
+import test.unit.response.authchallenge
 import test.unit.response.control_line
 import test.unit.response.control_message
 import test.unit.response.events
-import test.unit.response.getinfo
 import test.unit.response.getconf
+import test.unit.response.getinfo
+import test.unit.response.mapaddress
 import test.unit.response.protocolinfo
-import test.unit.response.authchallenge
 import test.unit.response.singleline
-import test.unit.response.mapaddress
+import test.unit.tutorial
 import test.unit.util.conf
 import test.unit.util.connection
 import test.unit.util.enum
@@ -42,34 +51,24 @@ import test.unit.util.proc
 import test.unit.util.str_tools
 import test.unit.util.system
 import test.unit.util.tor_tools
-import test.unit.exit_policy.policy
-import test.unit.exit_policy.rule
 import test.unit.version
-import test.unit.tutorial
 import test.integ.connection.authentication
 import test.integ.connection.connect
 import test.integ.control.base_controller
 import test.integ.control.controller
-import test.integ.socket.control_message
-import test.integ.socket.control_socket
-import test.integ.descriptor.reader
-import test.integ.descriptor.server_descriptor
 import test.integ.descriptor.extrainfo_descriptor
 import test.integ.descriptor.networkstatus
+import test.integ.descriptor.reader
+import test.integ.descriptor.server_descriptor
+import test.integ.process
 import test.integ.response.protocolinfo
+import test.integ.socket.control_message
+import test.integ.socket.control_socket
 import test.integ.util.conf
 import test.integ.util.proc
 import test.integ.util.system
-import test.integ.process
 import test.integ.version
 
-import stem.prereq
-import stem.util.conf
-import stem.util.enum
-import stem.util.log as log
-import stem.util.term as term
-import stem.util.system as system
-
 OPT = "uit:l:c:h"
 OPT_EXPANDED = ["unit", "integ", "targets=", "test=", "log=", "tor=", "config=", "help"]
 DIVIDER = "=" * 70
diff --git a/stem/connection.py b/stem/connection.py
index db11e61..3ca4462 100644
--- a/stem/connection.py
+++ b/stem/connection.py
@@ -101,18 +101,19 @@ fine-grained control over the authentication process. For instance...
 
 from __future__ import with_statement
 
-import os
-import getpass
 import binascii
+import getpass
+import os
 
+import stem.control
 import stem.response
 import stem.socket
-import stem.control
-import stem.version
+import stem.util.connection
 import stem.util.enum
 import stem.util.system
-import stem.util.connection
-import stem.util.log as log
+import stem.version
+
+from stem.util import log
 
 AuthMethod = stem.util.enum.Enum("NONE", "PASSWORD", "COOKIE", "SAFECOOKIE", "UNKNOWN")
 
diff --git a/stem/control.py b/stem/control.py
index 11eefb3..be589d9 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -111,19 +111,20 @@ providing its own for interacting at a higher level.
 from __future__ import with_statement
 
 import os
-import time
 import Queue
 import StringIO
 import threading
+import time
 
-import stem.response
-import stem.socket
-import stem.version
 import stem.descriptor.router_status_entry
 import stem.descriptor.server_descriptor
+import stem.response
+import stem.socket
 import stem.util.connection
 import stem.util.enum
-import stem.util.log as log
+import stem.version
+
+from stem.util import log
 
 # state changes a control socket can have
 
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index 7291995..3aaf5fd 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -29,6 +29,7 @@ import re
 import stem.util.enum
 
 try:
+  # added in python 2.7
   from collections import OrderedDict
 except ImportError:
   from stem.util.ordereddict import OrderedDict
diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
index 455e4ef..2231122 100644
--- a/stem/descriptor/export.py
+++ b/stem/descriptor/export.py
@@ -9,8 +9,8 @@ Toolkit for exporting descriptors to other formats.
   export_csv_file - Writes exported CSV output to a file
 """
 
-import csv
 import cStringIO
+import csv
 
 import stem.descriptor
 import stem.prereq
diff --git a/stem/descriptor/extrainfo_descriptor.py b/stem/descriptor/extrainfo_descriptor.py
index 7b901c8..d53f79b 100644
--- a/stem/descriptor/extrainfo_descriptor.py
+++ b/stem/descriptor/extrainfo_descriptor.py
@@ -65,13 +65,13 @@ Extra-info descriptors are available from a few sources...
   ===================== ===========
 """
 
-import re
-import hashlib
 import datetime
+import hashlib
+import re
 
 import stem.descriptor
-import stem.util.enum
 import stem.util.connection
+import stem.util.enum
 
 # known statuses for dirreq-v2-resp and dirreq-v3-resp...
 DirResponse = stem.util.enum.Enum(
diff --git a/stem/descriptor/networkstatus.py b/stem/descriptor/networkstatus.py
index efe40e1..5643fe0 100644
--- a/stem/descriptor/networkstatus.py
+++ b/stem/descriptor/networkstatus.py
@@ -73,8 +73,8 @@ import StringIO
 
 import stem.descriptor
 import stem.descriptor.router_status_entry
-import stem.version
 import stem.util.tor_tools
+import stem.version
 
 # Version 2 network status document fields, tuples of the form...
 # (keyword, is_mandatory)
diff --git a/stem/descriptor/reader.py b/stem/descriptor/reader.py
index 76c489d..95a1f8b 100644
--- a/stem/descriptor/reader.py
+++ b/stem/descriptor/reader.py
@@ -75,14 +75,14 @@ and picks up where it left off if ran again...
 
 from __future__ import with_statement
 
+import mimetypes
 import os
+import Queue
 import tarfile
 import threading
-import mimetypes
-import Queue
 
-import stem.prereq
 import stem.descriptor
+import stem.prereq
 
 # flag to indicate when the reader thread is out of descriptor files to read
 FINISHED = "DONE"
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index b87683c..aad5e5e 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -27,19 +27,20 @@ etc). This information is provided from a few sources...
     +- get_annotation_lines - lines that provided the annotations
 """
 
-import re
 import base64
-import hashlib
 import datetime
+import hashlib
+import re
 
-import stem.prereq
 import stem.descriptor
 import stem.descriptor.extrainfo_descriptor
 import stem.exit_policy
-import stem.version
+import stem.prereq
 import stem.util.connection
 import stem.util.tor_tools
-import stem.util.log as log
+import stem.version
+
+from stem.util import log
 
 # relay descriptors must have exactly one of the following
 REQUIRED_FIELDS = (
diff --git a/stem/prereq.py b/stem/prereq.py
index 0bc159b..072900a 100644
--- a/stem/prereq.py
+++ b/stem/prereq.py
@@ -22,7 +22,7 @@ series). Other requirements for complete functionality are...
 
 import sys
 
-import stem.util.log as log
+from stem.util import log
 
 IS_CRYPTO_AVAILABLE = None
 
diff --git a/stem/process.py b/stem/process.py
index d0523bc..e043010 100644
--- a/stem/process.py
+++ b/stem/process.py
@@ -17,11 +17,11 @@ Helper functions for working with tor as a process.
 
 from __future__ import with_statement
 
-import re
 import os
+import re
 import signal
-import tempfile
 import subprocess
+import tempfile
 
 import stem.prereq
 import stem.util.system
diff --git a/stem/response/authchallenge.py b/stem/response/authchallenge.py
index 6cc22f9..25573da 100644
--- a/stem/response/authchallenge.py
+++ b/stem/response/authchallenge.py
@@ -1,7 +1,7 @@
 import binascii
 
-import stem.socket
 import stem.response
+import stem.socket
 import stem.util.tor_tools
 
 class AuthChallengeResponse(stem.response.ControlMessage):
diff --git a/stem/response/events.py b/stem/response/events.py
index a8dfa1f..8c9cc2b 100644
--- a/stem/response/events.py
+++ b/stem/response/events.py
@@ -1,11 +1,11 @@
-import re
 import datetime
+import re
 import StringIO
 
 import stem
 import stem.control
-import stem.response
 import stem.descriptor.router_status_entry
+import stem.response
 import stem.version
 
 from stem.util import connection, log, str_tools, tor_tools
diff --git a/stem/response/getconf.py b/stem/response/getconf.py
index 889a587..df1a71f 100644
--- a/stem/response/getconf.py
+++ b/stem/response/getconf.py
@@ -1,5 +1,5 @@
-import stem.socket
 import stem.response
+import stem.socket
 
 class GetConfResponse(stem.response.ControlMessage):
   """
diff --git a/stem/response/getinfo.py b/stem/response/getinfo.py
index fb967d7..c33618b 100644
--- a/stem/response/getinfo.py
+++ b/stem/response/getinfo.py
@@ -1,5 +1,5 @@
-import stem.socket
 import stem.response
+import stem.socket
 
 class GetInfoResponse(stem.response.ControlMessage):
   """
diff --git a/stem/response/mapaddress.py b/stem/response/mapaddress.py
index b2be32e..a6542ff 100644
--- a/stem/response/mapaddress.py
+++ b/stem/response/mapaddress.py
@@ -1,5 +1,5 @@
-import stem.socket
 import stem.response
+import stem.socket
 
 class MapAddressResponse(stem.response.ControlMessage):
   """
diff --git a/stem/response/protocolinfo.py b/stem/response/protocolinfo.py
index 2db542d..0530717 100644
--- a/stem/response/protocolinfo.py
+++ b/stem/response/protocolinfo.py
@@ -1,9 +1,9 @@
-import stem.socket
 import stem.response
+import stem.socket
 import stem.version
-import stem.util.log as log
 
 from stem.connection import AuthMethod
+from stem.util import log
 
 class ProtocolInfoResponse(stem.response.ControlMessage):
   """
diff --git a/stem/socket.py b/stem/socket.py
index e4358fa..4cbfb3e 100644
--- a/stem/socket.py
+++ b/stem/socket.py
@@ -35,7 +35,8 @@ import socket
 import threading
 
 import stem.response
-import stem.util.log as log
+
+from stem.util import log
 
 class ControlSocket(object):
   """
diff --git a/stem/util/conf.py b/stem/util/conf.py
index 395d8f1..f2bc490 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -139,7 +139,7 @@ from __future__ import with_statement
 
 import threading
 
-import stem.util.log as log
+from stem.util import log
 
 CONFS = {}  # mapping of identifier to singleton instances of configs
 
diff --git a/stem/util/connection.py b/stem/util/connection.py
index 0417c87..6a0a8d1 100644
--- a/stem/util/connection.py
+++ b/stem/util/connection.py
@@ -20,10 +20,10 @@ but for now just moving the parts we need.
   cryptovariables_equal - string comparison for cryptographic operations
 """
 
+import hashlib
+import hmac
 import os
 import re
-import hmac
-import hashlib
 
 CRYPTOVARIABLE_EQUALITY_COMPARISON_NONCE = os.urandom(32)
 
diff --git a/stem/util/proc.py b/stem/util/proc.py
index 36e7e8a..fd019cb 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -36,15 +36,16 @@ Dave Daeschler, Giampaolo Rodola' and is under the BSD license.
   ============== ===========
 """
 
+import base64
 import os
+import platform
+import socket
 import sys
 import time
-import socket
-import base64
-import platform
 
 import stem.util.enum
-import stem.util.log as log
+
+from stem.util import log
 
 # cached system values
 IS_PROC_AVAILABLE, SYS_START_TIME, SYS_PHYSICAL_MEMORY = None, None, None
diff --git a/stem/util/system.py b/stem/util/system.py
index 2b8eb14..ed1fe4b 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -22,12 +22,13 @@ best-effort, providing **None** if the lookup fails.
 """
 
 import os
-import time
 import platform
 import subprocess
+import time
 
 import stem.util.proc
-import stem.util.log as log
+
+from stem.util import log
 
 # Mapping of commands to if they're available or not. This isn't always
 # reliable, failing for some special commands. For these the cache is
diff --git a/test/integ/connection/authentication.py b/test/integ/connection/authentication.py
index f811917..1024906 100644
--- a/test/integ/connection/authentication.py
+++ b/test/integ/connection/authentication.py
@@ -8,11 +8,10 @@ from __future__ import with_statement
 import os
 import unittest
 
-import test.runner
 import stem.connection
 import stem.socket
 import stem.version
-from stem.response.protocolinfo import AuthMethod
+import test.runner
 
 # Responses given by tor for various authentication failures. These may change
 # in the future and if they do then this test should be updated.
@@ -95,11 +94,11 @@ def _get_auth_failure_message(auth_type):
 
 class TestAuthenticate(unittest.TestCase):
   def setUp(self):
-    self.cookie_auth_methods = [AuthMethod.COOKIE]
+    self.cookie_auth_methods = [stem.connection.AuthMethod.COOKIE]
     
     tor_version = test.runner.get_runner().get_tor_version()
     if tor_version.meets_requirements(stem.version.Requirement.AUTH_SAFECOOKIE):
-      self.cookie_auth_methods.append(AuthMethod.SAFECOOKIE)
+      self.cookie_auth_methods.append(stem.connection.AuthMethod.SAFECOOKIE)
   
   def test_authenticate_general_socket(self):
     """
@@ -214,7 +213,7 @@ class TestAuthenticate(unittest.TestCase):
     # test both cookie authentication mechanisms
     with runner.get_tor_socket(False) as control_socket:
       if is_cookie_only:
-        for method in (AuthMethod.COOKIE, AuthMethod.SAFECOOKIE):
+        for method in (stem.connection.AuthMethod.COOKIE, stem.connection.AuthMethod.SAFECOOKIE):
           protocolinfo_response = stem.connection.get_protocolinfo(control_socket)
           
           if method in protocolinfo_response.auth_methods:
@@ -308,13 +307,13 @@ class TestAuthenticate(unittest.TestCase):
     for auth_type in self.cookie_auth_methods:
       if _can_authenticate(stem.connection.AuthMethod.NONE):
         # authentication will work anyway unless this is safecookie
-        if auth_type == AuthMethod.COOKIE:
+        if auth_type == stem.connection.AuthMethod.COOKIE:
           self._check_auth(auth_type, auth_value)
-        elif auth_type == AuthMethod.SAFECOOKIE:
+        elif auth_type == stem.connection.AuthMethod.SAFECOOKIE:
           exc_type = stem.connection.CookieAuthRejected
           self.assertRaises(exc_type, self._check_auth, auth_type, auth_value)
       else:
-        if auth_type == AuthMethod.SAFECOOKIE:
+        if auth_type == stem.connection.AuthMethod.SAFECOOKIE:
           if _can_authenticate(auth_type):
             exc_type = stem.connection.AuthSecurityFailure
           else:
diff --git a/test/integ/connection/connect.py b/test/integ/connection/connect.py
index b3ba210..acd8864 100644
--- a/test/integ/connection/connect.py
+++ b/test/integ/connection/connect.py
@@ -2,9 +2,9 @@
 Integration tests for the connect_* convenience functions.
 """
 
+import StringIO
 import sys
 import unittest
-import StringIO
 
 import stem.connection
 import test.runner
diff --git a/test/integ/control/base_controller.py b/test/integ/control/base_controller.py
index 900afad..b4bb354 100644
--- a/test/integ/control/base_controller.py
+++ b/test/integ/control/base_controller.py
@@ -5,14 +5,14 @@ Integration tests for the stem.control.BaseController class.
 from __future__ import with_statement
 
 import re
+import threading
 import time
 import unittest
-import threading
 
 import stem.control
+import test.runner
 import stem.socket
 import stem.util.system
-import test.runner
 
 class StateObserver(object):
   """
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 0ecece3..8bfe9d7 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -6,20 +6,20 @@ from __future__ import with_statement
 
 import os
 import re
-import time
 import shutil
 import socket
-import unittest
 import tempfile
+import time
+import unittest
 
 import stem.control
+import stem.descriptor.reader
+import stem.descriptor.router_status_entry
+import stem.response.protocolinfo
 import stem.socket
 import stem.version
-import stem.response.protocolinfo
 import test.runner
 import test.util
-import stem.descriptor.router_status_entry
-import stem.descriptor.reader
 
 from stem.control import EventType
 
diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py
index 9206ae6..44185c7 100644
--- a/test/integ/descriptor/extrainfo_descriptor.py
+++ b/test/integ/descriptor/extrainfo_descriptor.py
@@ -4,13 +4,14 @@ Integration tests for stem.descriptor.extrainfo_descriptor.
 
 from __future__ import with_statement
 
-import os
 import datetime
+import os
 import unittest
 
 import stem.descriptor.extrainfo_descriptor
-import test.runner
 import test.integ.descriptor
+import test.runner
+
 from stem.descriptor.extrainfo_descriptor import DirResponse
 
 class TestExtraInfoDescriptor(unittest.TestCase):
diff --git a/test/integ/descriptor/networkstatus.py b/test/integ/descriptor/networkstatus.py
index 84a1901..6355220 100644
--- a/test/integ/descriptor/networkstatus.py
+++ b/test/integ/descriptor/networkstatus.py
@@ -4,14 +4,14 @@ Integration tests for stem.descriptor.networkstatus.
 
 from __future__ import with_statement
 
+import datetime
 import os
 import resource
-import datetime
 import unittest
 
-import stem.version
 import stem.descriptor
 import stem.descriptor.networkstatus
+import stem.version
 import test.integ.descriptor
 
 class TestNetworkStatus(unittest.TestCase):
diff --git a/test/integ/descriptor/reader.py b/test/integ/descriptor/reader.py
index 7b3a6da..ec957fd 100644
--- a/test/integ/descriptor/reader.py
+++ b/test/integ/descriptor/reader.py
@@ -5,16 +5,17 @@ Integration tests for stem.descriptor.reader.
 from __future__ import with_statement
 
 import os
-import sys
-import time
 import signal
+import sys
 import tarfile
+import time
 import unittest
 
 import stem.descriptor.reader
-import stem.util.system as system
 import test.runner
 
+from stem.util import system
+
 BASIC_LISTING = """
 /tmp 123
 /bin/grep 4567
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index 4ce2eb5..35e3d2a 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -4,16 +4,16 @@ Integration tests for stem.descriptor.server_descriptor.
 
 from __future__ import with_statement
 
-import os
 import datetime
+import os
 import unittest
 
 import stem.control
+import stem.descriptor.server_descriptor
 import stem.exit_policy
 import stem.version
-import stem.descriptor.server_descriptor
-import test.runner
 import test.integ.descriptor
+import test.runner
 
 class TestServerDescriptor(unittest.TestCase):
   def test_metrics_descriptor(self):
diff --git a/test/integ/process.py b/test/integ/process.py
index 1c99f88..ee21d5a 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -3,19 +3,19 @@ Tests the stem.process functions with various use cases.
 """
 
 import os
-import time
 import shutil
 import signal
-import unittest
 import subprocess
+import time
+import unittest
 
 import stem.prereq
-import stem.socket
 import stem.process
-import stem.version
+import stem.socket
 import stem.util.system
-
+import stem.version
 import test.runner
+
 from test import mocking
 
 DATA_DIRECTORY = '/tmp/stem_integ'
diff --git a/test/integ/response/protocolinfo.py b/test/integ/response/protocolinfo.py
index a223510..fb5b163 100644
--- a/test/integ/response/protocolinfo.py
+++ b/test/integ/response/protocolinfo.py
@@ -7,12 +7,13 @@ from __future__ import with_statement
 
 import unittest
 
-import test.runner
-import stem.socket
 import stem.connection
-import stem.version
+import stem.socket
 import stem.util.system
-import test.mocking as mocking
+import stem.version
+import test.runner
+
+from test import mocking
 from test.integ.util.system import filter_system_call
 
 class TestProtocolInfo(unittest.TestCase):
diff --git a/test/integ/util/proc.py b/test/integ/util/proc.py
index d7ef317..8da3730 100644
--- a/test/integ/util/proc.py
+++ b/test/integ/util/proc.py
@@ -9,7 +9,8 @@ import os
 import unittest
 
 import test.runner
-import stem.util.proc as proc
+
+from stem.util import proc
 
 class TestProc(unittest.TestCase):
   def test_get_cwd(self):
diff --git a/test/integ/util/system.py b/test/integ/util/system.py
index 522e576..7de90ec 100644
--- a/test/integ/util/system.py
+++ b/test/integ/util/system.py
@@ -3,14 +3,15 @@ Integration tests for the stem.util.system functions against the tor process
 that we're running.
 """
 
-import os
 import getpass
-import unittest
+import os
 import tempfile
+import unittest
 
 import stem.util.system
 import test.runner
-import test.mocking as mocking
+
+from test import mocking
 
 def filter_system_call(prefixes):
   """
diff --git a/test/integ/version.py b/test/integ/version.py
index 34edec9..4e9409f 100644
--- a/test/integ/version.py
+++ b/test/integ/version.py
@@ -6,8 +6,8 @@ running with.
 import unittest
 
 import stem.prereq
-import test.runner
 import stem.version
+import test.runner
 
 class TestVersion(unittest.TestCase):
   def test_get_system_tor_version(self):
diff --git a/test/mocking.py b/test/mocking.py
index 6f05411..1cf2c0a 100644
--- a/test/mocking.py
+++ b/test/mocking.py
@@ -53,12 +53,12 @@ import itertools
 import StringIO
 import __builtin__
 
-import stem.response
-import stem.socket
-import stem.descriptor.server_descriptor
 import stem.descriptor.extrainfo_descriptor
 import stem.descriptor.networkstatus
 import stem.descriptor.router_status_entry
+import stem.descriptor.server_descriptor
+import stem.response
+import stem.socket
 
 # Once we've mocked a function we can't rely on its __module__ or __name__
 # attributes, so instead we associate a unique 'mock_id' attribute that maps
diff --git a/test/output.py b/test/output.py
index fdbafac..8295b1b 100644
--- a/test/output.py
+++ b/test/output.py
@@ -8,7 +8,8 @@ import sys
 
 import stem.util.conf
 import stem.util.enum
-import stem.util.term as term
+
+from stem.util import term
 
 CONFIG = stem.util.conf.config_dict("test", {
   "argument.no_color": False,
diff --git a/test/prompt.py b/test/prompt.py
index b7da033..290d1ce 100644
--- a/test/prompt.py
+++ b/test/prompt.py
@@ -16,8 +16,8 @@ easier.
 """
 
 import os
-import sys
 import signal
+import sys
 
 import stem.control
 import stem.process
diff --git a/test/runner.py b/test/runner.py
index 0393a68..760c6c5 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -37,24 +37,25 @@ about the tor test instance they're running against.
 
 from __future__ import with_statement
 
+import logging
 import os
-import time
-import stat
 import shutil
 import signal
-import logging
+import stat
 import tempfile
 import threading
+import time
 
 import stem.prereq
-import stem.socket
 import stem.process
-import stem.version
+import stem.socket
 import stem.util.conf
 import stem.util.enum
-import stem.util.term as term
+import stem.version
 import test.output
 
+from stem.util import term
+
 CONFIG = stem.util.conf.config_dict("test", {
   "integ.test_directory": "./test/data",
   "integ.log": "./test/data/log",
diff --git a/test/unit/connection/authentication.py b/test/unit/connection/authentication.py
index a99651a..fa4aba4 100644
--- a/test/unit/connection/authentication.py
+++ b/test/unit/connection/authentication.py
@@ -12,8 +12,9 @@ various error conditions, and make sure that the right exception is raised.
 import unittest
 
 import stem.connection
-import stem.util.log as log
-import test.mocking as mocking
+
+from stem.util import log
+from test import mocking
 
 class TestAuthenticate(unittest.TestCase):
   def setUp(self):
diff --git a/test/unit/descriptor/extrainfo_descriptor.py b/test/unit/descriptor/extrainfo_descriptor.py
index c009463..2c33225 100644
--- a/test/unit/descriptor/extrainfo_descriptor.py
+++ b/test/unit/descriptor/extrainfo_descriptor.py
@@ -4,6 +4,7 @@ Unit tests for stem.descriptor.extrainfo_descriptor.
 
 import datetime
 import unittest
+
 from stem.descriptor.extrainfo_descriptor import RelayExtraInfoDescriptor, DirResponse, DirStat
 from test.mocking import get_relay_extrainfo_descriptor, get_bridge_extrainfo_descriptor, CRYPTO_BLOB
 
diff --git a/test/unit/descriptor/networkstatus/document_v3.py b/test/unit/descriptor/networkstatus/document_v3.py
index 9eb45a5..000a614 100644
--- a/test/unit/descriptor/networkstatus/document_v3.py
+++ b/test/unit/descriptor/networkstatus/document_v3.py
@@ -5,14 +5,32 @@ Unit tests for the NetworkStatusDocumentV3 of stem.descriptor.networkstatus.
 from __future__ import with_statement
 
 import datetime
-import unittest
 import StringIO
+import unittest
 
 import stem.version
+
 from stem.descriptor import Flag
-from stem.descriptor.networkstatus import HEADER_STATUS_DOCUMENT_FIELDS, FOOTER_STATUS_DOCUMENT_FIELDS, DEFAULT_PARAMS, BANDWIDTH_WEIGHT_ENTRIES, DirectoryAuthority, NetworkStatusDocumentV3, parse_file
-from stem.descriptor.router_status_entry import RouterStatusEntryV3, RouterStatusEntryMicroV3
-from test.mocking import support_with, get_router_status_entry_v3, get_router_status_entry_micro_v3, get_directory_authority, get_network_status_document_v3, CRYPTO_BLOB, DOC_SIG, NETWORK_STATUS_DOCUMENT_FOOTER
+
+from stem.descriptor.networkstatus import HEADER_STATUS_DOCUMENT_FIELDS, \
+                                          FOOTER_STATUS_DOCUMENT_FIELDS, \
+                                          DEFAULT_PARAMS, \
+                                          BANDWIDTH_WEIGHT_ENTRIES, \
+                                          DirectoryAuthority, \
+                                          NetworkStatusDocumentV3, \
+                                          parse_file
+
+from stem.descriptor.router_status_entry import RouterStatusEntryV3, \
+                                                RouterStatusEntryMicroV3
+
+from test.mocking import support_with, \
+                         get_router_status_entry_v3, \
+                         get_router_status_entry_micro_v3, \
+                         get_directory_authority, \
+                         get_network_status_document_v3, \
+                         CRYPTO_BLOB, \
+                         DOC_SIG, \
+                         NETWORK_STATUS_DOCUMENT_FOOTER
 
 class TestNetworkStatusDocument(unittest.TestCase):
   def test_minimal_consensus(self):
diff --git a/test/unit/descriptor/networkstatus/key_certificate.py b/test/unit/descriptor/networkstatus/key_certificate.py
index e37337b..c3e8c9f 100644
--- a/test/unit/descriptor/networkstatus/key_certificate.py
+++ b/test/unit/descriptor/networkstatus/key_certificate.py
@@ -6,7 +6,11 @@ import datetime
 import unittest
 
 from stem.descriptor.networkstatus import KeyCertificate
-from test.mocking import get_key_certificate, CRYPTO_BLOB, KEY_CERTIFICATE_HEADER, KEY_CERTIFICATE_FOOTER
+
+from test.mocking import get_key_certificate, \
+                         CRYPTO_BLOB, \
+                         KEY_CERTIFICATE_HEADER, \
+                         KEY_CERTIFICATE_FOOTER
 
 class TestKeyCertificate(unittest.TestCase):
   def test_minimal(self):
diff --git a/test/unit/descriptor/reader.py b/test/unit/descriptor/reader.py
index 2d7df10..28b7155 100644
--- a/test/unit/descriptor/reader.py
+++ b/test/unit/descriptor/reader.py
@@ -2,8 +2,8 @@
 Unit tests for stem.descriptor.reader.
 """
 
-import unittest
 import StringIO
+import unittest
 
 import stem.descriptor.reader
 import test.mocking as mocking
diff --git a/test/unit/descriptor/router_status_entry.py b/test/unit/descriptor/router_status_entry.py
index 27eb76d..8a7e711 100644
--- a/test/unit/descriptor/router_status_entry.py
+++ b/test/unit/descriptor/router_status_entry.py
@@ -7,9 +7,13 @@ import unittest
 
 from stem.descriptor import Flag
 from stem.descriptor.router_status_entry import RouterStatusEntryV3, _decode_fingerprint
-from stem.version import Version
 from stem.exit_policy import MicrodescriptorExitPolicy
-from test.mocking import get_router_status_entry_v2, get_router_status_entry_v3, get_router_status_entry_micro_v3, ROUTER_STATUS_ENTRY_V3_HEADER
+from stem.version import Version
+
+from test.mocking import get_router_status_entry_v2, \
+                         get_router_status_entry_v3, \
+                         get_router_status_entry_micro_v3, \
+                         ROUTER_STATUS_ENTRY_V3_HEADER
 
 class TestRouterStatusEntry(unittest.TestCase):
   def test_fingerprint_decoding(self):
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index 2e54e44..9b0528a 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -8,9 +8,14 @@ import unittest
 
 import stem.prereq
 import stem.descriptor.server_descriptor
-from stem.descriptor.server_descriptor import RelayDescriptor, BridgeDescriptor
 import test.runner
-from test.mocking import get_relay_server_descriptor, get_bridge_server_descriptor, CRYPTO_BLOB, sign_descriptor_content
+
+from stem.descriptor.server_descriptor import RelayDescriptor, BridgeDescriptor
+
+from test.mocking import get_relay_server_descriptor, \
+                         get_bridge_server_descriptor, \
+                         CRYPTO_BLOB, \
+                         sign_descriptor_content
 
 class TestServerDescriptor(unittest.TestCase):
   def test_minimal_relay_descriptor(self):
diff --git a/test/unit/exit_policy/policy.py b/test/unit/exit_policy/policy.py
index 67fbf68..bfafa98 100644
--- a/test/unit/exit_policy/policy.py
+++ b/test/unit/exit_policy/policy.py
@@ -3,6 +3,7 @@ Unit tests for the stem.exit_policy.ExitPolicy class.
 """
 
 import unittest
+
 from stem.exit_policy import ExitPolicy, \
                              MicrodescriptorExitPolicy, \
                              ExitPolicyRule
diff --git a/test/unit/response/authchallenge.py b/test/unit/response/authchallenge.py
index 19ce931..436bca0 100644
--- a/test/unit/response/authchallenge.py
+++ b/test/unit/response/authchallenge.py
@@ -4,10 +4,11 @@ Unit tests for the stem.response.authchallenge.AuthChallengeResponse class.
 
 import unittest
 
-import stem.socket
 import stem.response
 import stem.response.authchallenge
-import test.mocking as mocking
+import stem.socket
+
+from test import mocking
 
 VALID_RESPONSE = "250 AUTHCHALLENGE \
 SERVERHASH=B16F72DACD4B5ED1531F3FCC04B593D46A1E30267E636EA7C7F8DD7A2B7BAA05 \
diff --git a/test/unit/response/control_line.py b/test/unit/response/control_line.py
index 5240a46..1d0a0dd 100644
--- a/test/unit/response/control_line.py
+++ b/test/unit/response/control_line.py
@@ -3,6 +3,7 @@ Unit tests for the stem.response.ControlLine class.
 """
 
 import unittest
+
 import stem.response
 
 # response made by having 'DataDirectory /tmp/my data\"dir/' in the torrc
diff --git a/test/unit/response/control_message.py b/test/unit/response/control_message.py
index 115aed5..9ebd4bc 100644
--- a/test/unit/response/control_message.py
+++ b/test/unit/response/control_message.py
@@ -5,6 +5,7 @@ Unit tests for the stem.response.ControlMessage parsing and class.
 import socket
 import StringIO
 import unittest
+
 import stem.socket
 
 OK_REPLY = "250 OK\r\n"
diff --git a/test/unit/response/events.py b/test/unit/response/events.py
index 8c432e7..1a40958 100644
--- a/test/unit/response/events.py
+++ b/test/unit/response/events.py
@@ -9,9 +9,9 @@ import unittest
 import stem.response
 import stem.response.events
 import stem.util.log
-import test.mocking as mocking
 
 from stem import * # enums and exceptions
+from test import mocking
 
 # BUILDTIMEOUT_SET event from tor 0.2.3.16.
 
diff --git a/test/unit/response/getconf.py b/test/unit/response/getconf.py
index 70d1239..14ef974 100644
--- a/test/unit/response/getconf.py
+++ b/test/unit/response/getconf.py
@@ -4,10 +4,11 @@ Unit tests for the stem.response.getconf.GetConfResponse class.
 
 import unittest
 
-import stem.socket
 import stem.response
 import stem.response.getconf
-import test.mocking as mocking
+import stem.socket
+
+from test import mocking
 
 EMPTY_RESPONSE = "250 OK"
 
diff --git a/test/unit/response/getinfo.py b/test/unit/response/getinfo.py
index 2a51693..f5481c6 100644
--- a/test/unit/response/getinfo.py
+++ b/test/unit/response/getinfo.py
@@ -4,10 +4,11 @@ Unit tests for the stem.response.getinfo.GetInfoResponse class.
 
 import unittest
 
-import stem.socket
 import stem.response
 import stem.response.getinfo
-import test.mocking as mocking
+import stem.socket
+
+from test import mocking
 
 EMPTY_RESPONSE = "250 OK"
 
diff --git a/test/unit/response/mapaddress.py b/test/unit/response/mapaddress.py
index 2f9949b..b8ba7cb 100644
--- a/test/unit/response/mapaddress.py
+++ b/test/unit/response/mapaddress.py
@@ -4,10 +4,11 @@ Unit tests for the stem.response.mapaddress.MapAddressResponse class.
 
 import unittest
 
-import stem.socket
 import stem.response
 import stem.response.mapaddress
-import test.mocking as mocking
+import stem.socket
+
+from test import mocking
 
 SINGLE_RESPONSE = """250 foo=bar"""
 
diff --git a/test/unit/response/protocolinfo.py b/test/unit/response/protocolinfo.py
index 7d16075..6bc01eb 100644
--- a/test/unit/response/protocolinfo.py
+++ b/test/unit/response/protocolinfo.py
@@ -5,14 +5,15 @@ Unit tests for the stem.response.protocolinfo.ProtocolInfoResponse class.
 import os
 import unittest
 
+import stem.response
+import stem.response.protocolinfo
 import stem.socket
-import stem.version
 import stem.util.proc
 import stem.util.system
-import stem.response
-import stem.response.protocolinfo
-import test.mocking as mocking
+import stem.version
+
 from stem.response.protocolinfo import AuthMethod
+from test import mocking
 
 NO_AUTH = """250-PROTOCOLINFO 1
 250-AUTH METHODS=NULL
diff --git a/test/unit/response/singleline.py b/test/unit/response/singleline.py
index 0a4e13f..30c967f 100644
--- a/test/unit/response/singleline.py
+++ b/test/unit/response/singleline.py
@@ -4,9 +4,10 @@ Unit tests for the stem.response.SingleLineResponse class.
 
 import unittest
 
-import stem.socket
 import stem.response
-import test.mocking as mocking
+import stem.socket
+
+from test import mocking
 
 MULTILINE_RESPONSE = """250-MULTI
 250 LINE"""
diff --git a/test/unit/tutorial.py b/test/unit/tutorial.py
index ae1a829..bb50e11 100644
--- a/test/unit/tutorial.py
+++ b/test/unit/tutorial.py
@@ -3,9 +3,10 @@ Tests for the examples given in stem's tutorial.
 """
 
 from __future__ import with_statement
+
 import unittest
 
-import test.mocking as mocking
+from test import mocking
 
 class TestTutorial(unittest.TestCase):
   def tearDown(self):
diff --git a/test/unit/util/conf.py b/test/unit/util/conf.py
index 9238f7f..c2fbed0 100644
--- a/test/unit/util/conf.py
+++ b/test/unit/util/conf.py
@@ -3,6 +3,7 @@ Unit tests for the stem.util.conf class and functions.
 """
 
 import unittest
+
 import stem.util.conf
 
 class TestConf(unittest.TestCase):
diff --git a/test/unit/util/connection.py b/test/unit/util/connection.py
index 4df0298..673da71 100644
--- a/test/unit/util/connection.py
+++ b/test/unit/util/connection.py
@@ -3,6 +3,7 @@ Unit tests for the stem.util.connection functions.
 """
 
 import unittest
+
 import stem.util.connection
 
 class TestConnection(unittest.TestCase):
diff --git a/test/unit/util/enum.py b/test/unit/util/enum.py
index 88469dd..c5b73bf 100644
--- a/test/unit/util/enum.py
+++ b/test/unit/util/enum.py
@@ -3,6 +3,7 @@ Unit tests for the stem.util.enum class and functions.
 """
 
 import unittest
+
 import stem.util.enum
 
 class TestEnum(unittest.TestCase):
diff --git a/test/unit/util/proc.py b/test/unit/util/proc.py
index e1aaec7..5f775f1 100644
--- a/test/unit/util/proc.py
+++ b/test/unit/util/proc.py
@@ -3,11 +3,11 @@ Unit testing code for the stem.util.proc functions.
 """
 
 import os
-import unittest
 import StringIO
+import unittest
 
-import test.mocking as mocking
-import stem.util.proc as proc
+from stem.util import proc
+from test import mocking
 
 class TestProc(unittest.TestCase):
   def tearDown(self):
diff --git a/test/unit/util/system.py b/test/unit/util/system.py
index 5609917..b948696 100644
--- a/test/unit/util/system.py
+++ b/test/unit/util/system.py
@@ -5,15 +5,17 @@ these tests actually make system calls, use proc, or otherwise deal with the
 system running the tests.
 """
 
-import os
-import platform
 import functools
-import unittest
 import ntpath
+import os
+import platform
 import posixpath
+import unittest
+
 import stem.util.proc
-import stem.util.system as system
-import test.mocking as mocking
+
+from stem.util import system
+from test import mocking
 
 # Base responses for the get_pid_by_name tests. The 'success' and
 # 'multiple_results' entries are filled in by tests.
diff --git a/test/unit/util/tor_tools.py b/test/unit/util/tor_tools.py
index c5b2685..32581e9 100644
--- a/test/unit/util/tor_tools.py
+++ b/test/unit/util/tor_tools.py
@@ -3,6 +3,7 @@ Unit tests for the stem.util.tor_tools functions.
 """
 
 import unittest
+
 import stem.util.tor_tools
 
 class TestTorTools(unittest.TestCase):
diff --git a/test/unit/version.py b/test/unit/version.py
index df4caa5..9fb72e0 100644
--- a/test/unit/version.py
+++ b/test/unit/version.py
@@ -3,11 +3,12 @@ Unit tests for the stem.version.Version parsing and class.
 """
 
 import unittest
-import stem.version
-from stem.version import Version
+
 import stem.util.system
+import stem.version
 
-import test.mocking as mocking
+from stem.version import Version
+from test import mocking
 
 TOR_VERSION_OUTPUT = """Mar 22 23:09:37.088 [notice] Tor v0.2.2.35 \
 (git-73ff13ab3cc9570d). This is experimental software. Do not rely on it for \
diff --git a/test/util.py b/test/util.py
index 90a5551..74b494d 100644
--- a/test/util.py
+++ b/test/util.py
@@ -1,9 +1,10 @@
-import struct
 import socket
+import struct
 
-from stem import ProtocolError
 import test.runner
 
+from stem import ProtocolError
+
 error_msgs = {
   0x5a: "SOCKS4A request granted",
   0x5b: "SOCKS4A request rejected or failed",



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits