[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Reuse mocked Bridges across various unittests.
commit 7632085c0725e32001e41774564bffe7cb221584
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
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
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits