Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(13)  |  Call(10)  |  Derive(0)  |  Import(3)

src/d/h/DHTBot-HEAD/dhtbot/test/protocols/test_krpc_sender.py   DHTBot(Download)
from dhtbot.protocols.errors import TimeoutError
from dhtbot.coding import krpc_coder
from dhtbot.test.utils import Clock, HollowReactor, HollowTransport, Counter
 
# Write two functions that simply remove / restore
        k_messenger = KRPC_Sender(TreeRoutingTable, 2**50)
        # Patch in our counter
        counter = Counter()
        setattr(k_messenger, method_name, counter)
 
        query.rpctype = "ping"
        # Make the protocol and patch in our counter, transport, and reactor
        counter = Counter()
        k_messenger = KRPC_Sender(TreeRoutingTable, 2**50)
        k_messenger.transport = HollowTransport()
    def test_callback(self):
        counter = Counter()
        d = self.k_messenger.sendQuery(self.query, address, timeout)
        self.assertTrue(self.query._transaction_id in
                        self.k_messenger._transactions)
    def test_errback_KRPCError(self):
        counter = Counter()
        d = self.k_messenger.sendQuery(self.query, address, timeout)
        self.assertTrue(self.query._transaction_id in
                        self.k_messenger._transactions)

src/d/h/DHTBot-HEAD/dhtbot/test/protocols/test_krpc_iterator.py   DHTBot(Download)
from dhtbot.protocols.errors import TimeoutError
 
from dhtbot.test.utils import Counter, HollowTransport, HollowReactor
 
make_node = lambda num: Node(num, ("127.0.0.1", num))
    def _check_k_iter_sendsProperNumberOfQueries_noNodesInRT(self, iter_func):
        sendQuery = self.k_iter.sendQuery
        self.k_iter.sendQuery = Counter(sendQuery)
        expected_num_queries = 15
        iter_func(self.target_id, test_nodes[:expected_num_queries])
    def _check_k_iter_usesNodesFromRoutingTable(self, iter_func):
        get_closest_nodes = self.k_iter.routing_table.get_closest_nodes
        self.k_iter.routing_table.get_closest_nodes = \
            Counter(get_closest_nodes)
        # If we dont supply any testing nodes,

src/d/h/DHTBot-HEAD/dhtbot/test/extensions/test_rate_limiter.py   DHTBot(Download)
from dhtbot.krpc_types import Query
from dhtbot.protocols.krpc_sender import KRPC_Sender
from dhtbot.test.utils import Clock, Counter, HollowTransport
 
class TestingBase(object):
        """
        rate_limited_proto = self._patched_sender()
        counter = Counter()
        rate_limited_proto.krpcReceived = counter
        # One packet should be accepted without problems
        address4 = ("127.0.0.1", 555)
        rate_limited_proto = self._patched_sender()
        counter = Counter()
        rate_limited_proto.krpcReceived = counter
        # The first three packets should be accepted without