commit 514e93753dd33b33e5ff9540bc2f0d26113e5cbe Author: Isis Lovecruft isis@torproject.org Date: Thu Oct 17 02:19:07 2013 +0000
Fix three failing unittests in lib/bridgedb/Tests.py.
Three unittests were failing in lib/bridgedb/Tests.py due to changes made for users). They were:
- testDistWithFilterBoth (bridgedb.Tests.IPBridgeDistTests) - testDistWithFilterIP4 (bridgedb.Tests.IPBridgeDistTests) - testDistWithFilterIP6 (bridgedb.Tests.IPBridgeDistTests)
These were failing due to chopping the first 7 bytes off the the returned config lines, because they expected to see the "bridge " prefix and it's not there anymore. --- lib/bridgedb/Tests.py | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/lib/bridgedb/Tests.py b/lib/bridgedb/Tests.py index 2699ece..c1e994b 100644 --- a/lib/bridgedb/Tests.py +++ b/lib/bridgedb/Tests.py @@ -2,6 +2,8 @@ # Copyright (c) 2007-2009, The Tor Project, Inc. # See LICENSE for licensing information
+from __future__ import print_function + import doctest import os import random @@ -279,11 +281,14 @@ class IPBridgeDistTests(unittest.TestCase): d.insert(fakeBridge(or_addresses=True))
for i in xrange(500): - b = d.getBridgesForIP(randomIP4String(), "x", 1, bridgeFilterRules=[filterBridgesByIP6]) - address, portlist = bridgedb.Bridges.parseORAddressLine( - random.choice(b).getConfigLine(addressClass=ipaddr.IPv6Address)[7:]) + bridges = d.getBridgesForIP(randomIP4String(), + "faketimestamp", + bridgeFilterRules=[filterBridgesByIP6]) + bridge = random.choice(bridges) + bridge_line = bridge.getConfigLine(addressClass=ipaddr.IPv6Address) + address, portlist = bridgedb.Bridges.parseORAddressLine(bridge_line) assert type(address) is ipaddr.IPv6Address - assert filterBridgesByIP6(random.choice(b)) + assert filterBridgesByIP6(random.choice(bridges))
def testDistWithFilterIP4(self): d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo") @@ -292,12 +297,14 @@ class IPBridgeDistTests(unittest.TestCase): d.insert(fakeBridge(or_addresses=True))
for i in xrange(500): - b = d.getBridgesForIP(randomIP4String(), "x", 1, bridgeFilterRules=[filterBridgesByIP4]) - address, portlist = bridgedb.Bridges.parseORAddressLine( - random.choice(b).getConfigLine(addressClass=ipaddr.IPv4Address)[7:]) + bridges = d.getBridgesForIP(randomIP4String(), + "faketimestamp", + bridgeFilterRules=[filterBridgesByIP4]) + bridge = random.choice(bridges) + bridge_line = bridge.getConfigLine(addressClass=ipaddr.IPv4Address) + address, portlist = bridgedb.Bridges.parseORAddressLine(bridge_line) assert type(address) is ipaddr.IPv4Address - - assert filterBridgesByIP4(random.choice(b)) + assert filterBridgesByIP4(random.choice(bridges))
def testDistWithFilterBoth(self): d = bridgedb.Dist.IPBasedDistributor(self.dumbAreaMapper, 3, "Foo") @@ -306,17 +313,20 @@ class IPBridgeDistTests(unittest.TestCase): d.insert(fakeBridge(or_addresses=True))
for i in xrange(50): - b = d.getBridgesForIP(randomIP4String(), "x", 1, bridgeFilterRules=[ - filterBridgesByIP4, filterBridgesByIP6]) - if b: - t = b.pop() + bridges = d.getBridgesForIP(randomIP4String(), + "faketimestamp", 1, + bridgeFilterRules=[ + filterBridgesByIP4, + filterBridgesByIP6]) + if bridges: + t = bridges.pop() assert filterBridgesByIP4(t) assert filterBridgesByIP6(t) address, portlist = bridgedb.Bridges.parseORAddressLine( - t.getConfigLine(addressClass=ipaddr.IPv4Address)[7:]) + t.getConfigLine(addressClass=ipaddr.IPv4Address)) assert type(address) is ipaddr.IPv4Address address, portlist = bridgedb.Bridges.parseORAddressLine( - t.getConfigLine(addressClass=ipaddr.IPv6Address)[7:]) + t.getConfigLine(addressClass=ipaddr.IPv6Address)) assert type(address) is ipaddr.IPv6Address
tor-commits@lists.torproject.org