[tor-commits] [stem/master] Fix unit tests

atagar at torproject.org atagar at torproject.org
Mon Mar 28 21:50:10 UTC 2016


commit 745fe08199a2ba7d6fe3577f5bc6df54f9ae7ff9
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Mar 28 14:49:48 2016 -0700

    Fix unit tests
    
    Oops, missed that this point could have non-string rules...
    
      ======================================================================
      ERROR: test_all_default_policy
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/srv/jenkins-workspace/workspace/stem-tor-ci/test/unit/exit_policy/policy.py", line 141, in test_all_default_policy
          for rule in policy:
        File "/srv/jenkins-workspace/workspace/stem-tor-ci/stem/exit_policy.py", line 502, in __iter__
          for rule in self._get_rules():
        File "/srv/jenkins-workspace/workspace/stem-tor-ci/stem/exit_policy.py", line 452, in _get_rules
          if not rule.strip():
      AttributeError: 'ExitPolicyRule' object has no attribute 'strip'
---
 stem/cached_tor_manual.cfg | 6 +++---
 stem/exit_policy.py        | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/stem/cached_tor_manual.cfg b/stem/cached_tor_manual.cfg
index fade04b..8753a92 100644
--- a/stem/cached_tor_manual.cfg
+++ b/stem/cached_tor_manual.cfg
@@ -5,9 +5,9 @@ description
 |
 |Basically, Tor provides a distributed network of servers or relays ("onion routers"). Users bounce their TCP streams -- web traffic, ftp, ssh, etc. -- around the network, and recipients, observers, and even the relays themselves have difficulty tracking the source of the stream.
 |
-|By default, tor will only act as a client only. To help the network by providing bandwidth as a relay, change the ORPort configuration option -- see below. Please also consult the documentation on the Tor Project's website.
-man_commit 94cb8792e8c28e75bc71434fc557ddefa5c03083
-stem_commit 27a654e2e0495c7ac701d792e7db7ed47d4e9753
+|By default, tor will act as a client only. To help the network by providing bandwidth as a relay, change the ORPort configuration option -- see below. Please also consult the documentation on the Tor Project's website.
+man_commit 7d6e7fdd0343c32a09c926e7094d43f6653baa4f
+stem_commit 7bfc752b69972f7043b260651602b8cb7bc270c4
 commandline_options -f FILE => Specify a new configuration file to contain further Tor configuration options OR pass - to make Tor read its configuration from standard input. (Default: @CONFDIR@/torrc, or $HOME/.torrc if that file is not found)
 commandline_options --ignore-missing-torrc => Specifies that Tor should treat a missing torrc file as though it were empty. Ordinarily, Tor does this for missing default torrc files, but not for those specified on the command line.
 commandline_options --list-fingerprint => Generate your keys and output your nickname and fingerprint.
diff --git a/stem/exit_policy.py b/stem/exit_policy.py
index 3d4e66a..0453470 100644
--- a/stem/exit_policy.py
+++ b/stem/exit_policy.py
@@ -449,13 +449,13 @@ class ExitPolicy(object):
         decompressed_rules = self._input_rules
 
       for rule in decompressed_rules:
-        if not rule.strip():
-          continue
-
         if isinstance(rule, bytes):
           rule = stem.util.str_tools._to_unicode(rule)
 
         if isinstance(rule, str_type):
+          if not rule.strip():
+            continue
+
           rule = ExitPolicyRule(rule.strip())
 
         if rule.is_accept:



More information about the tor-commits mailing list