[tor-commits] [bridgedb/develop] Reuse mocked Bridges across various unittests.

isis at torproject.org isis at torproject.org
Thu Jun 25 07:10:55 UTC 2015


commit 7632085c0725e32001e41774564bffe7cb221584
Author: Isis Lovecruft <isis at torproject.org>
Date:   Sun May 10 22:18:26 2015 +0000

    Reuse mocked Bridges across various unittests.
---
 lib/bridgedb/test/util.py |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/bridgedb/test/util.py b/lib/bridgedb/test/util.py
index f164aeb..2cddc11 100644
--- a/lib/bridgedb/test/util.py
+++ b/lib/bridgedb/test/util.py
@@ -168,6 +168,8 @@ randomValidIPv4String = valid(randomIPv4String)
 randomValidIPv6String = valid(randomIPv6String)
 randomValidIPString   = valid(randomIPString)
 
+_FAKE_BRIDGES = []
+
 def generateFakeBridges(n=500):
     """Generate a set of **n** :class:`~bridgedb.bridges.Bridges` with random
     data.
@@ -175,6 +177,11 @@ def generateFakeBridges(n=500):
     from bridgedb.bridges import Bridge
     from bridgedb.bridges import PluggableTransport
 
+    global _FAKE_BRIDGES
+
+    if _FAKE_BRIDGES:
+        return _FAKE_BRIDGES
+
     bridges = []
 
     for i in range(n):
@@ -199,6 +206,7 @@ def generateFakeBridges(n=500):
         bridge.orAddresses = addrs
         bridges.append(bridge)
 
+    _FAKE_BRIDGES = bridges
     return bridges
 
 





More information about the tor-commits mailing list