[tor-commits] [stem/master] Unit test failure for system_resolvers() on Gentoo

atagar at torproject.org atagar at torproject.org
Thu Dec 11 16:28:39 UTC 2014


commit a63e4eeba44be24f258547c93be23263b8c95ddd
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Dec 11 08:28:00 2014 -0800

    Unit test failure for system_resolvers() on Gentoo
    
    Oops, mistake in how platform detection is done. Making our Gentoo hacks play
    well with the unit tests.
---
 stem/util/connection.py      |    9 ++++++---
 test/unit/util/connection.py |    1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/stem/util/connection.py b/stem/util/connection.py
index 1ee0ffb..ac4bf27 100644
--- a/stem/util/connection.py
+++ b/stem/util/connection.py
@@ -249,13 +249,16 @@ def system_resolvers(system = None):
   """
 
   if system is None:
-    system = platform.system()
+    if stem.util.system.is_gentoo():
+      system = 'Gentoo'
+    else:
+      system = platform.system()
 
   if system == 'Windows':
     resolvers = []
   elif system in ('Darwin', 'OpenBSD'):
     resolvers = [Resolver.LSOF]
-  elif stem.util.system.is_gentoo():
+  elif system == 'Gentoo':
     resolvers = []
   elif system == 'FreeBSD':
     # Netstat is available, but lacks a '-p' equivilant so we can't associate
@@ -274,7 +277,7 @@ def system_resolvers(system = None):
 
   # proc resolution, by far, outperforms the others so defaults to this is able
 
-  if stem.util.proc.is_available() and os.access('/proc/net/tcp', os.R_OK) and os.access('/proc/net/udp', os.R_OK) and not stem.util.system.is_gentoo():
+  if stem.util.proc.is_available() and os.access('/proc/net/tcp', os.R_OK) and os.access('/proc/net/udp', os.R_OK) and system != 'Gentoo':
     resolvers = [Resolver.PROC] + resolvers
 
   return resolvers
diff --git a/test/unit/util/connection.py b/test/unit/util/connection.py
index f0359eb..179ebdf 100644
--- a/test/unit/util/connection.py
+++ b/test/unit/util/connection.py
@@ -117,6 +117,7 @@ class TestConnection(unittest.TestCase):
 
     self.assertEqual([], stem.util.connection.system_resolvers('Windows'))
     self.assertEqual([Resolver.LSOF], stem.util.connection.system_resolvers('Darwin'))
+    self.assertEqual([], stem.util.connection.system_resolvers('Gentoo'))
     self.assertEqual([Resolver.LSOF], stem.util.connection.system_resolvers('OpenBSD'))
     self.assertEqual([Resolver.BSD_SOCKSTAT, Resolver.BSD_PROCSTAT, Resolver.LSOF], stem.util.connection.system_resolvers('FreeBSD'))
     self.assertEqual([Resolver.NETSTAT, Resolver.SOCKSTAT, Resolver.LSOF, Resolver.SS], stem.util.connection.system_resolvers('Linux'))



More information about the tor-commits mailing list