[tor-commits] [stem/master] Drop is_python_26 checks

atagar at torproject.org atagar at torproject.org
Sun Jan 5 21:39:28 UTC 2020


commit 551fbde4845a78d3b0f885202dbd171d54d660aa
Author: Damian Johnson <atagar at torproject.org>
Date:   Fri Jan 3 14:40:55 2020 -0800

    Drop is_python_26 checks
    
    Python 2.6 specific code paths are now obsolete. This is most notable within
    our tests because we can now use skipTest() without an extra return statement.
    No doubt these tests can simplify more, but beginning with the low hanging
    fruit.
---
 stem/client/datatype.py                       | 23 --------------
 stem/descriptor/export.py                     |  2 +-
 stem/prereq.py                                | 16 ----------
 stem/util/__init__.py                         |  6 +---
 stem/util/test_tools.py                       | 44 ++-------------------------
 test/integ/connection/authentication.py       |  1 -
 test/integ/control/base_controller.py         |  2 --
 test/integ/control/controller.py              |  4 ---
 test/integ/descriptor/collector.py            |  1 -
 test/integ/descriptor/extrainfo_descriptor.py |  2 +-
 test/integ/descriptor/microdescriptor.py      |  2 +-
 test/integ/descriptor/networkstatus.py        |  8 ++---
 test/integ/descriptor/server_descriptor.py    |  2 +-
 test/integ/directory/fallback.py              |  1 -
 test/integ/installation.py                    |  4 +--
 test/integ/interpreter.py                     |  4 ---
 test/integ/manual.py                          | 23 +++++---------
 test/integ/util/connection.py                 |  2 --
 test/integ/util/proc.py                       |  1 -
 test/integ/util/system.py                     |  8 -----
 test/unit/descriptor/collector.py             |  3 --
 test/unit/descriptor/compression.py           |  1 -
 test/unit/descriptor/export.py                |  8 -----
 test/unit/descriptor/reader.py                |  3 --
 test/unit/descriptor/remote.py                |  2 --
 test/unit/installation.py                     |  2 --
 test/unit/manual.py                           |  4 ---
 test/unit/tutorial_examples.py                |  7 -----
 28 files changed, 21 insertions(+), 165 deletions(-)

diff --git a/stem/client/datatype.py b/stem/client/datatype.py
index 5de5e445..367074b2 100644
--- a/stem/client/datatype.py
+++ b/stem/client/datatype.py
@@ -390,29 +390,6 @@ class Size(Field):
     raise NotImplementedError("Use our constant's unpack() and pop() instead")
 
   def pack(self, content):
-    # TODO: Python 2.6's struct module behaves a little differently in a couple
-    # respsects...
-    #
-    #   * Invalid types raise a TypeError rather than a struct.error.
-    #
-    #   * Negative values are happily packed despite being unsigned fields with
-    #     a message printed to stdout (!) that says...
-    #
-    #       stem/client/datatype.py:362: DeprecationWarning: struct integer overflow masking is deprecated
-    #         packed = struct.pack(self.format, content)
-    #       stem/client/datatype.py:362: DeprecationWarning: 'B' format requires 0 <= number <= 255
-    #         packed = struct.pack(self.format, content)
-    #
-    # Rather than adjust this method to account for these differences doing
-    # duplicate upfront checks just for python 2.6. When we drop 2.6 support
-    # this can obviously be dropped.
-
-    if stem.prereq._is_python_26():
-      if not stem.util._is_int(content):
-        raise ValueError('Size.pack encodes an integer, but was a %s' % type(content).__name__)
-      elif content < 0:
-        raise ValueError('Packed values must be positive (attempted to pack %i as a %s)' % (content, self.name))
-
     # TODO: When we drop python 2.x support this can be simplified via
     # integer's to_bytes() method. For example...
     #
diff --git a/stem/descriptor/export.py b/stem/descriptor/export.py
index 48699ca4..fea681be 100644
--- a/stem/descriptor/export.py
+++ b/stem/descriptor/export.py
@@ -103,7 +103,7 @@ def export_csv_file(output_file, descriptors, included_fields = (), excluded_fie
 
   writer = csv.DictWriter(output_file, included_fields, dialect = _ExportDialect(), extrasaction='ignore')
 
-  if header and not stem.prereq._is_python_26():
+  if header:
     writer.writeheader()
 
   for desc in descriptors:
diff --git a/stem/prereq.py b/stem/prereq.py
index 0de2191e..d748c2ab 100644
--- a/stem/prereq.py
+++ b/stem/prereq.py
@@ -50,22 +50,6 @@ def check_requirements():
     raise ImportError('stem requires python version 3.6 or greater')
 
 
-def _is_python_26():
-  """
-  Checks if we're running python 2.6. This isn't for users as it'll be removed
-  in stem 2.0 (when python 2.6 support goes away).
-
-  .. deprecated:: 1.8.0
-     Stem 2.x will remove this method along with Python 2.x support.
-
-  :returns: **True** if we're running python 2.6, **False** otherwise
-  """
-
-  major_version, minor_version = sys.version_info[0:2]
-
-  return major_version == 2 and minor_version == 6
-
-
 def is_python_27():
   """
   Checks if we're running python 2.7 or above (including the 3.x series).
diff --git a/stem/util/__init__.py b/stem/util/__init__.py
index 5be29777..226f5fbf 100644
--- a/stem/util/__init__.py
+++ b/stem/util/__init__.py
@@ -120,11 +120,7 @@ def datetime_to_unix(timestamp):
   :returns: **float** for the unix timestamp of the given datetime object
   """
 
-  if stem.prereq._is_python_26():
-    delta = (timestamp - datetime.datetime(1970, 1, 1))
-    return delta.days * 86400 + delta.seconds
-  else:
-    return (timestamp - datetime.datetime(1970, 1, 1)).total_seconds()
+  return (timestamp - datetime.datetime(1970, 1, 1)).total_seconds()
 
 
 def _pubkey_bytes(key):
diff --git a/stem/util/test_tools.py b/stem/util/test_tools.py
index c7dce7ce..02d3dd89 100644
--- a/stem/util/test_tools.py
+++ b/stem/util/test_tools.py
@@ -56,15 +56,6 @@ ASYNC_TESTS = {}
 AsyncStatus = stem.util.enum.UppercaseEnum('PENDING', 'RUNNING', 'FINISHED')
 AsyncResult = collections.namedtuple('AsyncResult', 'type msg')
 
-# TODO: Providing a copy of SkipTest that works with python 2.6. This will be
-# dropped when we remove python 2.6 support.
-
-if stem.prereq._is_python_26():
-  class SkipTest(Exception):
-    'Notes that the test was skipped.'
-else:
-  SkipTest = unittest.case.SkipTest
-
 
 def assert_equal(expected, actual, msg = None):
   """
@@ -111,7 +102,7 @@ def skip(msg):
   :raises: **unittest.case.SkipTest** for this reason
   """
 
-  raise SkipTest(msg)
+  raise unittest.case.SkipTest(msg)
 
 
 def asynchronous(func):
@@ -159,9 +150,6 @@ class AsyncTest(object):
     self._status = AsyncStatus.PENDING
 
   def run(self, *runner_args, **kwargs):
-    if stem.prereq._is_python_26():
-      return  # not supported under python 2.6
-
     def _wrapper(conn, runner, args):
       os.nice(12)
 
@@ -170,7 +158,7 @@ class AsyncTest(object):
         conn.send(AsyncResult('success', None))
       except AssertionError as exc:
         conn.send(AsyncResult('failure', str(exc)))
-      except SkipTest as exc:
+      except unittest.case.SkipTest as exc:
         conn.send(AsyncResult('skipped', str(exc)))
       except:
         conn.send(AsyncResult('error', traceback.format_exc()))
@@ -209,9 +197,6 @@ class AsyncTest(object):
     self.result(None)
 
   def result(self, test):
-    if stem.prereq._is_python_26():
-      return  # not supported under python 2.6
-
     with self._process_lock:
       if self._status == AsyncStatus.PENDING:
         self.run()
@@ -259,21 +244,6 @@ class TimedTestRunner(unittest.TextTestRunner):
           TEST_RUNTIMES[self.id()] = time.time() - start_time
           return result
 
-        # TODO: remove and drop unnecessary 'returns' when dropping python 2.6
-        # support
-
-        def skipTest(self, message):
-          if not stem.prereq._is_python_26():
-            return super(original_type, self).skipTest(message)
-
-        # TODO: remove when dropping python 2.6 support
-
-        def assertItemsEqual(self, expected, actual):
-          if stem.prereq._is_python_26():
-            self.assertEqual(set(expected), set(actual))
-          else:
-            return super(original_type, self).assertItemsEqual(expected, actual)
-
         def assertRaisesWith(self, exc_type, exc_msg, func, *args, **kwargs):
           """
           Asserts the given invokation raises the expected excepiton. This is
@@ -287,16 +257,6 @@ class TimedTestRunner(unittest.TextTestRunner):
 
           return self.assertRaisesRegexp(exc_type, '^%s$' % re.escape(exc_msg), func, *args, **kwargs)
 
-        def assertRaisesRegexp(self, exc_type, exc_msg, func, *args, **kwargs):
-          if stem.prereq._is_python_26():
-            try:
-              func(*args, **kwargs)
-              self.fail('Expected a %s to be raised but nothing was' % exc_type)
-            except exc_type as exc:
-              self.assertTrue(re.search(exc_msg, str(exc), re.MULTILINE))
-          else:
-            return super(original_type, self).assertRaisesRegexp(exc_type, exc_msg, func, *args, **kwargs)
-
         def id(self):
           return '%s.%s.%s' % (original_type.__module__, original_type.__name__, self._testMethodName)
 
diff --git a/test/integ/connection/authentication.py b/test/integ/connection/authentication.py
index 1ab6aae0..cd562e7b 100644
--- a/test/integ/connection/authentication.py
+++ b/test/integ/connection/authentication.py
@@ -280,7 +280,6 @@ class TestAuthenticate(unittest.TestCase):
 
     if test.runner.Torrc.PASSWORD not in runner.get_options() or test.runner.Torrc.COOKIE in runner.get_options():
       self.skipTest('(requires only password auth)')
-      return
 
     for i in range(10):
       with runner.get_tor_controller(False) as controller:
diff --git a/test/integ/control/base_controller.py b/test/integ/control/base_controller.py
index 294eaee3..323b57c7 100644
--- a/test/integ/control/base_controller.py
+++ b/test/integ/control/base_controller.py
@@ -47,7 +47,6 @@ class TestBaseController(unittest.TestCase):
 
     if stem.util.system.is_mac():
       self.skipTest('(ticket #6235)')
-      return
 
     with test.runner.get_runner().get_tor_socket() as control_socket:
       controller = stem.control.BaseController(control_socket)
@@ -97,7 +96,6 @@ class TestBaseController(unittest.TestCase):
 
     if stem.util.system.is_mac():
       self.skipTest('(ticket #6235)')
-      return
 
     with test.runner.get_runner().get_tor_socket() as control_socket:
       controller = stem.control.BaseController(control_socket)
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index a32f66f0..f87c0817 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -1296,7 +1296,6 @@ class TestController(unittest.TestCase):
 
     if not os.path.exists(runner.get_test_dir('cached-microdescs')):
       self.skipTest('(no cached microdescriptors)')
-      return
 
     with runner.get_tor_controller() as controller:
       count = 0
@@ -1318,7 +1317,6 @@ class TestController(unittest.TestCase):
 
     if test.tor_version() >= Requirement.MICRODESCRIPTOR_IS_DEFAULT:
       self.skipTest('(requires server descriptors)')
-      return
 
     with runner.get_tor_controller() as controller:
       # we should balk at invalid content
@@ -1349,7 +1347,6 @@ class TestController(unittest.TestCase):
 
     if test.tor_version() >= Requirement.MICRODESCRIPTOR_IS_DEFAULT:
       self.skipTest('(requires server descriptors)')
-      return
 
     with runner.get_tor_controller() as controller:
       count = 0
@@ -1534,6 +1531,5 @@ class TestController(unittest.TestCase):
       if TEST_ROUTER_STATUS_ENTRY is None:
         # this is only likely to occure if we can't get descriptors
         self.skipTest('(no named relays)')
-        return
 
     return TEST_ROUTER_STATUS_ENTRY
diff --git a/test/integ/descriptor/collector.py b/test/integ/descriptor/collector.py
index 3af25c29..53f45ae5 100644
--- a/test/integ/descriptor/collector.py
+++ b/test/integ/descriptor/collector.py
@@ -93,7 +93,6 @@ class TestCollector(unittest.TestCase):
   def _test_index(self, compression):
     if compression and not compression.available:
       self.skipTest('(%s unavailable)' % compression)
-      return
 
     collector = stem.descriptor.collector.CollecTor()
     index = collector.index(compression = compression)
diff --git a/test/integ/descriptor/extrainfo_descriptor.py b/test/integ/descriptor/extrainfo_descriptor.py
index c0a4d30c..4bfb8f3f 100644
--- a/test/integ/descriptor/extrainfo_descriptor.py
+++ b/test/integ/descriptor/extrainfo_descriptor.py
@@ -28,7 +28,7 @@ class TestExtraInfoDescriptor(unittest.TestCase):
     descriptor_path = os.path.join(test_dir, 'cached-extrainfo')
 
     if not os.path.exists(descriptor_path):
-      raise stem.util.test_tools.SkipTest('(no cached descriptors)')
+      raise unittest.case.SkipTest('(no cached descriptors)')
 
     with open(descriptor_path, 'rb') as descriptor_file:
       for desc in stem.descriptor.parse_file(descriptor_file, 'extra-info 1.0', validate = True):
diff --git a/test/integ/descriptor/microdescriptor.py b/test/integ/descriptor/microdescriptor.py
index 3f2b20cb..4e67e15b 100644
--- a/test/integ/descriptor/microdescriptor.py
+++ b/test/integ/descriptor/microdescriptor.py
@@ -28,7 +28,7 @@ class TestMicrodescriptor(unittest.TestCase):
     descriptor_path = os.path.join(test_dir, 'cached-microdescs')
 
     if not os.path.exists(descriptor_path):
-      raise stem.util.test_tools.SkipTest('(no cached descriptors)')
+      raise unittest.case.SkipTest('(no cached descriptors)')
 
     with open(descriptor_path, 'rb') as descriptor_file:
       for desc in stem.descriptor.parse_file(descriptor_file, 'microdescriptor 1.0', validate = True):
diff --git a/test/integ/descriptor/networkstatus.py b/test/integ/descriptor/networkstatus.py
index b9684e6f..efe646f9 100644
--- a/test/integ/descriptor/networkstatus.py
+++ b/test/integ/descriptor/networkstatus.py
@@ -43,12 +43,12 @@ class TestNetworkStatus(unittest.TestCase):
     consensus_path = os.path.join(test_dir, 'cached-consensus')
 
     if not os.path.exists(consensus_path):
-      raise stem.util.test_tools.SkipTest('(no cached-consensus)')
+      raise unittest.case.SkipTest('(no cached-consensus)')
     elif stem.util.system.is_windows():
       # Unable to check memory usage on windows, so can't prevent hanging the
       # system if things go bad.
 
-      raise stem.util.test_tools.SkipTest('(unavailable on windows)')
+      raise unittest.case.SkipTest('(unavailable on windows)')
 
     count, reported_flags = 0, []
 
@@ -79,9 +79,9 @@ class TestNetworkStatus(unittest.TestCase):
     consensus_path = os.path.join(test_dir, 'cached-microdesc-consensus')
 
     if not os.path.exists(consensus_path):
-      raise stem.util.test_tools.SkipTest('(no cached-microdesc-consensus)')
+      raise unittest.case.SkipTest('(no cached-microdesc-consensus)')
     elif stem.util.system.is_windows():
-      raise stem.util.test_tools.SkipTest('(unavailable on windows)')
+      raise unittest.case.SkipTest('(unavailable on windows)')
 
     count, reported_flags = 0, []
 
diff --git a/test/integ/descriptor/server_descriptor.py b/test/integ/descriptor/server_descriptor.py
index a62ee8f6..8aa4388c 100644
--- a/test/integ/descriptor/server_descriptor.py
+++ b/test/integ/descriptor/server_descriptor.py
@@ -28,7 +28,7 @@ class TestServerDescriptor(unittest.TestCase):
     descriptor_path = os.path.join(test_dir, 'cached-descriptors')
 
     if not os.path.exists(descriptor_path):
-      raise stem.util.test_tools.SkipTest('(no cached descriptors)')
+      raise unittest.case.SkipTest('(no cached descriptors)')
 
     with open(descriptor_path, 'rb') as descriptor_file:
       for desc in stem.descriptor.parse_file(descriptor_file, 'server-descriptor 1.0', validate = True):
diff --git a/test/integ/directory/fallback.py b/test/integ/directory/fallback.py
index e12b2659..83c87a8d 100644
--- a/test/integ/directory/fallback.py
+++ b/test/integ/directory/fallback.py
@@ -33,7 +33,6 @@ class TestFallback(unittest.TestCase):
     # added so many fallbacks now that this takes a looong time. :(
 
     self.skipTest('(skipped by default)')
-    return
 
     unsuccessful = {}
     downloader = stem.descriptor.remote.DescriptorDownloader()
diff --git a/test/integ/installation.py b/test/integ/installation.py
index 2ac655aa..627f0314 100644
--- a/test/integ/installation.py
+++ b/test/integ/installation.py
@@ -110,9 +110,9 @@ class TestInstallation(unittest.TestCase):
     git_dir = os.path.join(test.STEM_BASE, '.git')
 
     if not stem.util.system.is_available('git'):
-      raise stem.util.test_tools.SkipTest('(git unavailable)')
+      raise unittest.case.SkipTest('(git unavailable)')
     elif not os.path.exists(git_dir):
-      raise stem.util.test_tools.SkipTest('(not a git checkout)')
+      raise unittest.case.SkipTest('(not a git checkout)')
 
     if os.path.exists(DIST_PATH):
       raise AssertionError("%s already exists, maybe you manually ran 'python setup.py sdist'?" % DIST_PATH)
diff --git a/test/integ/interpreter.py b/test/integ/interpreter.py
index 65d03fd3..32c52c28 100644
--- a/test/integ/interpreter.py
+++ b/test/integ/interpreter.py
@@ -38,10 +38,8 @@ class TestInterpreter(unittest.TestCase):
 
     if test.runner.Torrc.PASSWORD in test.runner.get_runner().get_options():
       self.skipTest('password auth unsupported')
-      return
     elif not READLINE_AVAILABLE:
       self.skipTest('readline unavailable')
-      return
 
     expected = ['250-config-file=%s' % test.runner.get_runner().get_torrc_path(), '250 OK']
     self.assertEqual(expected, _run_prompt('--run', 'GETINFO config-file'))
@@ -50,10 +48,8 @@ class TestInterpreter(unittest.TestCase):
   def test_running_file(self):
     if test.runner.Torrc.PASSWORD in test.runner.get_runner().get_options():
       self.skipTest('password auth unsupported')
-      return
     elif not READLINE_AVAILABLE:
       self.skipTest('readline unavailable')
-      return
 
     expected = [
       '250-config-file=%s' % test.runner.get_runner().get_torrc_path(),
diff --git a/test/integ/manual.py b/test/integ/manual.py
index ae0b2b16..86811917 100644
--- a/test/integ/manual.py
+++ b/test/integ/manual.py
@@ -91,15 +91,14 @@ class TestManual(unittest.TestCase):
     if self.man_path and os.path.exists(self.man_path):
       os.remove(self.man_path)
 
+  # TODO: replace with a 'require' annotation
+
   def requires_downloaded_manual(self):
     if self.skip_reason:
       self.skipTest(self.skip_reason)
-      return True
     elif self.download_error:
       self.fail(self.download_error)
 
-    return False
-
   def test_escapes_non_ascii(self):
     """
     Check that our manual parser escapes all non-ascii characters. If this
@@ -108,8 +107,7 @@ class TestManual(unittest.TestCase):
     stem/manual.py's _get_categories().
     """
 
-    if self.requires_downloaded_manual():
-      return
+    self.requires_downloaded_manual()
 
     def check(content):
       try:
@@ -131,8 +129,7 @@ class TestManual(unittest.TestCase):
     it has indented lines within it. Ensure we parse this correctly.
     """
 
-    if self.requires_downloaded_manual():
-      return
+    self.requires_downloaded_manual()
 
     manual = stem.manual.Manual.from_man(self.man_path)
     self.assertTrue(manual.config_options['ExitPolicy'].description.startswith(EXPECTED_EXIT_POLICY_DESCRIPTION_START))
@@ -143,8 +140,7 @@ class TestManual(unittest.TestCase):
     Check if the cached manual information bundled with Stem is up to date or not.
     """
 
-    if self.requires_downloaded_manual():
-      return
+    self.requires_downloaded_manual()
 
     cached_manual = stem.manual.Manual.from_cache()
     latest_manual = stem.manual.Manual.from_man(self.man_path)
@@ -158,8 +154,7 @@ class TestManual(unittest.TestCase):
     then go ahead and simply update these assertions.
     """
 
-    if self.requires_downloaded_manual():
-      return
+    self.requires_downloaded_manual()
 
     def assert_equal(category, expected, actual):
       if expected != actual:
@@ -208,8 +203,7 @@ class TestManual(unittest.TestCase):
     class to match.
     """
 
-    if self.requires_downloaded_manual():
-      return
+    self.requires_downloaded_manual()
 
     categories = stem.manual._get_categories(self.man_content)
 
@@ -230,8 +224,7 @@ class TestManual(unittest.TestCase):
     Check that all the configuration options tor supports are in the man page.
     """
 
-    if self.requires_downloaded_manual():
-      return
+    self.requires_downloaded_manual()
 
     with test.runner.get_runner().get_tor_controller() as controller:
       config_options_in_tor = set([line.split()[0] for line in controller.get_info('config/names').splitlines() if line.split()[1] != 'Virtual'])
diff --git a/test/integ/util/connection.py b/test/integ/util/connection.py
index ed55ad89..e31ee865 100644
--- a/test/integ/util/connection.py
+++ b/test/integ/util/connection.py
@@ -27,10 +27,8 @@ class TestConnection(unittest.TestCase):
 
     if test.runner.Torrc.PORT not in runner.get_options():
       self.skipTest('(no control port)')
-      return
     elif resolver not in stem.util.connection.system_resolvers():
       self.skipTest('(resolver unavailable on this platform)')
-      return
 
     with runner.get_tor_socket():
       connections = stem.util.connection.get_connections(resolver, process_pid = runner.get_pid())
diff --git a/test/integ/util/proc.py b/test/integ/util/proc.py
index da4d6efc..315082d5 100644
--- a/test/integ/util/proc.py
+++ b/test/integ/util/proc.py
@@ -76,7 +76,6 @@ class TestProc(unittest.TestCase):
       return
     elif not os.access('/proc/net/tcp', os.R_OK) or not os.access('/proc/net/udp', os.R_OK):
       self.skipTest('(proc lacks read permissions)')
-      return
 
     # making a controller connection so that we have something to query for
     with runner.get_tor_socket():
diff --git a/test/integ/util/system.py b/test/integ/util/system.py
index 89019685..3b48433d 100644
--- a/test/integ/util/system.py
+++ b/test/integ/util/system.py
@@ -287,15 +287,12 @@ class TestSystem(unittest.TestCase):
 
     if stem.util.system.is_windows():
       self.skipTest('(unavailable on windows)')
-      return
     elif stem.util.system.is_mac() or stem.util.system.is_gentoo():
       self.skipTest('(resolvers unavailable)')
-      return
     elif not stem.util.system.is_available('netstat') or \
              stem.util.system.is_available('sockstat') or \
               stem.util.system.is_available('lsof'):
       self.skipTest('(connection resolvers unavailable)')
-      return
 
     runner = test.runner.get_runner()
     tor_pid, tor_port = runner.get_pid(), test.runner.CONTROL_PORT
@@ -313,7 +310,6 @@ class TestSystem(unittest.TestCase):
 
     if stem.util.system.is_gentoo():
       self.skipTest('(unavailable on gentoo)')
-      return
 
     netstat_prefix = stem.util.system.GET_PID_BY_PORT_NETSTAT
 
@@ -353,7 +349,6 @@ class TestSystem(unittest.TestCase):
 
     if stem.util.system.is_mac() or stem.util.system.is_gentoo():
       self.skipTest('(resolvers unavailable)')
-      return
 
     lsof_prefix = stem.util.system.GET_PID_BY_PORT_LSOF
 
@@ -397,7 +392,6 @@ class TestSystem(unittest.TestCase):
 
     if stem.util.system.is_windows():
       self.skipTest('(unavailable on windows)')
-      return
 
     runner = test.runner.get_runner()
     runner_pid, tor_cwd = runner.get_pid(), runner.get_tor_cwd()
@@ -537,7 +531,6 @@ class TestSystem(unittest.TestCase):
 
     if getpass.getuser() == 'root':
       self.skipTest('(running as root)')
-      return
 
     self.assertEqual(os.getcwd(), stem.util.system.expand_path('.'))
     self.assertEqual(os.getcwd(), stem.util.system.expand_path('./'))
@@ -568,7 +561,6 @@ class TestSystem(unittest.TestCase):
 
     if stem.prereq.is_pypy():
       self.skipTest('(unimplemented for pypy)')
-      return
 
     initial_name = stem.util.system.get_process_name()
     self.assertTrue('run_tests.py' in initial_name)
diff --git a/test/unit/descriptor/collector.py b/test/unit/descriptor/collector.py
index b4ff7636..3d6b2da0 100644
--- a/test/unit/descriptor/collector.py
+++ b/test/unit/descriptor/collector.py
@@ -72,7 +72,6 @@ class TestCollector(unittest.TestCase):
   def test_index_gzip(self, urlopen_mock):
     if not Compression.GZIP.available:
       self.skipTest('(gzip compression unavailable)')
-      return
 
     import zlib
     urlopen_mock.return_value = io.BytesIO(zlib.compress(EXAMPLE_INDEX_JSON))
@@ -85,7 +84,6 @@ class TestCollector(unittest.TestCase):
   def test_index_bz2(self, urlopen_mock):
     if not Compression.BZ2.available:
       self.skipTest('(bz2 compression unavailable)')
-      return
 
     import bz2
     urlopen_mock.return_value = io.BytesIO(bz2.compress(EXAMPLE_INDEX_JSON))
@@ -98,7 +96,6 @@ class TestCollector(unittest.TestCase):
   def test_index_lzma(self, urlopen_mock):
     if not Compression.LZMA.available:
       self.skipTest('(lzma compression unavailable)')
-      return
 
     import lzma
     urlopen_mock.return_value = io.BytesIO(lzma.compress(EXAMPLE_INDEX_JSON))
diff --git a/test/unit/descriptor/compression.py b/test/unit/descriptor/compression.py
index 3945bc9c..a51bba62 100644
--- a/test/unit/descriptor/compression.py
+++ b/test/unit/descriptor/compression.py
@@ -32,7 +32,6 @@ class TestCompression(unittest.TestCase):
 
     if not compression.available:
       self.skipTest('(%s unavailable)' % compression)
-      return
 
     with open(get_resource(filename), 'rb') as compressed_file:
       content = compression.decompress(compressed_file.read())
diff --git a/test/unit/descriptor/export.py b/test/unit/descriptor/export.py
index a33c1d42..bf7d054a 100644
--- a/test/unit/descriptor/export.py
+++ b/test/unit/descriptor/export.py
@@ -21,10 +21,6 @@ class TestExport(unittest.TestCase):
     Exports a single minimal tor server descriptor.
     """
 
-    if stem.prereq._is_python_26():
-      self.skipTest('(header added in python 2.7)')
-      return
-
     desc = RelayDescriptor.create({
       'router': 'caerSidi 71.35.133.197 9001 0 0',
       'published': '2012-03-01 17:15:27',
@@ -73,10 +69,6 @@ class TestExport(unittest.TestCase):
     Checks that the default attributes for our csv output doesn't include private fields.
     """
 
-    if stem.prereq._is_python_26():
-      self.skipTest('(header added in python 2.7)')
-      return
-
     desc = RelayDescriptor.create()
     desc_csv = export_csv(desc)
 
diff --git a/test/unit/descriptor/reader.py b/test/unit/descriptor/reader.py
index 76d1d8f3..589b4641 100644
--- a/test/unit/descriptor/reader.py
+++ b/test/unit/descriptor/reader.py
@@ -192,7 +192,6 @@ class TestDescriptorReader(unittest.TestCase):
 
     if getpass.getuser() == 'root':
       self.skipTest('(running as root)')
-      return
 
     # Skip the test on windows, since you can only set the file's
     # read-only flag with os.chmod(). For more information see...
@@ -558,10 +557,8 @@ class TestDescriptorReader(unittest.TestCase):
 
     if getpass.getuser() == 'root':
       self.skipTest('(running as root)')
-      return
     elif stem.util.system.is_windows():
       self.skipTest('(chmod not functional)')
-      return
 
     test_path = os.path.join(self.temp_directory, 'secret_file')
 
diff --git a/test/unit/descriptor/remote.py b/test/unit/descriptor/remote.py
index ab0ad3d7..7703c62c 100644
--- a/test/unit/descriptor/remote.py
+++ b/test/unit/descriptor/remote.py
@@ -241,7 +241,6 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if not stem.prereq.is_zstd_available():
       self.skipTest('(requires zstd module)')
-      return
 
     descriptors = list(stem.descriptor.remote.get_server_descriptors(
       '9695DFC35FFEB861329B9F1AB04C46397020CE31',
@@ -260,7 +259,6 @@ class TestDescriptorDownloader(unittest.TestCase):
 
     if not stem.prereq.is_lzma_available():
       self.skipTest('(requires lzma module)')
-      return
 
     descriptors = list(stem.descriptor.remote.get_server_descriptors(
       '9695DFC35FFEB861329B9F1AB04C46397020CE31',
diff --git a/test/unit/installation.py b/test/unit/installation.py
index fd8709ba..a91f0362 100644
--- a/test/unit/installation.py
+++ b/test/unit/installation.py
@@ -25,7 +25,6 @@ class TestInstallation(unittest.TestCase):
   def test_installs_all_modules(self):
     if self.skip_reason:
       self.skipTest(self.skip_reason)
-      return True
 
     # Modules cited my our setup.py looks like...
     #
@@ -49,7 +48,6 @@ class TestInstallation(unittest.TestCase):
   def test_installs_all_data_files(self):
     if self.skip_reason:
       self.skipTest(self.skip_reason)
-      return True
 
     # Checking that we have all non-source files. Data looks like...
     #
diff --git a/test/unit/manual.py b/test/unit/manual.py
index b7a2de6f..c108af19 100644
--- a/test/unit/manual.py
+++ b/test/unit/manual.py
@@ -149,7 +149,6 @@ class TestManual(unittest.TestCase):
 
     if not stem.manual.HAS_ENCODING_ARG:
       self.skipTest('(man lacks --encoding arg on OSX, BSD, and Slackware #18660)')
-      return
 
     manual = stem.manual.Manual.from_man(EXAMPLE_MAN_PATH)
 
@@ -170,7 +169,6 @@ class TestManual(unittest.TestCase):
 
     if not stem.manual.HAS_ENCODING_ARG:
       self.skipTest('(man lacks --encoding arg on OSX and BSD and Slackware, #18660)')
-      return
 
     manual = stem.manual.Manual.from_man(UNKNOWN_OPTIONS_MAN_PATH)
 
@@ -198,7 +196,6 @@ class TestManual(unittest.TestCase):
 
     if not stem.manual.HAS_ENCODING_ARG:
       self.skipTest('(man lacks --encoding arg on OSX, BSD and Slackware, #18660)')
-      return
 
     manual = stem.manual.Manual.from_man(EXAMPLE_MAN_PATH)
 
@@ -215,7 +212,6 @@ class TestManual(unittest.TestCase):
 
     if not stem.manual.HAS_ENCODING_ARG:
       self.skipTest('(man lacks --encoding arg on OSX, BSD, and Slackware #18660)')
-      return
 
     manual = stem.manual.Manual.from_man(EXAMPLE_MAN_PATH)
 
diff --git a/test/unit/tutorial_examples.py b/test/unit/tutorial_examples.py
index c4b26ad0..de00a2b8 100644
--- a/test/unit/tutorial_examples.py
+++ b/test/unit/tutorial_examples.py
@@ -235,13 +235,6 @@ class TestTutorialExamples(unittest.TestCase):
   @patch('stem.descriptor.remote.Query')
   @patch('stem.directory.Authority.from_cache')
   def test_compare_flags(self, authorities_mock, query_mock, stdout_mock):
-    if stem.prereq._is_python_26():
-      # example imports OrderedDict from collections which doesn't work under
-      # python 2.6
-
-      self.skipTest("(example doesn't support python 2.6)")
-      return
-
     authorities_mock().items.return_value = [('moria1', DIRECTORY_AUTHORITIES['moria1']), ('maatuska', DIRECTORY_AUTHORITIES['maatuska'])]
 
     fingerprint = [





More information about the tor-commits mailing list