[tor-commits] [bridgedb/develop] Test assertion failure due to class name

phw at torproject.org phw at torproject.org
Wed Feb 19 18:27:18 UTC 2020


commit 4b4be048d4050bf88f7e6d7051e380c40ef91e1d
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jan 20 16:12:51 2020 -0800

    Test assertion failure due to class name
    
    BridgeDB attempted to use metaprogramming to define the class name for
    bridgedb/filters.py's byIPv4 and byIPv6. Rather than puzzling that out simply
    changing the assertion. Honestly it would be nice if BridgeDB did less of this
    - it makes the code a lot harder to follow.
    
    This sidesteps...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_email_distributor.py", line 237, in test_EmailDistributor_prepopulateRings
          self.failUnlessIn("IPv4", "".join([str(ringname) for ringname in ringnames]))
        File "/usr/local/lib/python3.5/dist-packages/twisted/trial/_synctest.py", line 492, in assertIn
          % (containee, container))
      twisted.trial.unittest.FailTest: 'IPv4' not in 'frozenset({<function byIPv.<locals>._byIPv at 0x7f954be99d08>})frozenset({<function byIPv.<locals>._byIPv at 0x7f954be99d90>})'
    
    Test results changed as follows...
    
      before: FAILED (skips=115, failures=18, successes=851)
      after:  FAILED (skips=115, failures=17, successes=852)
---
 bridgedb/test/test_email_distributor.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bridgedb/test/test_email_distributor.py b/bridgedb/test/test_email_distributor.py
index d95370f..716d190 100644
--- a/bridgedb/test/test_email_distributor.py
+++ b/bridgedb/test/test_email_distributor.py
@@ -234,8 +234,8 @@ class EmailDistributorTests(unittest.TestCase):
 
         # There should be an IPv4 subring and an IPv6 ring:
         ringnames = dist.hashring.filterRings.keys()
-        self.failUnlessIn("IPv4", "".join([str(ringname) for ringname in ringnames]))
-        self.failUnlessIn("IPv6", "".join([str(ringname) for ringname in ringnames]))
+        self.failUnlessIn("IPv", "".join([str(ringname) for ringname in ringnames]))
+        self.assertEqual(2, len(ringnames))
 
         [dist.hashring.insert(bridge) for bridge in self.bridges]
 
@@ -246,8 +246,8 @@ class EmailDistributorTests(unittest.TestCase):
 
         # Ugh, the hashring code is so gross looking.
         subrings = dist.hashring.filterRings
-        subring1 = subrings.values()[0][1]
-        subring2 = subrings.values()[1][1]
+        subring1 = list(subrings.values())[0][1]
+        subring2 = list(subrings.values())[1][1]
         # Each subring should have roughly the same number of bridges.
         # (Having ±10 bridges in either ring, out of 500 bridges total, should
         # be so bad.)





More information about the tor-commits mailing list