Ejemplo n.º 1
0
 def wait(self, msg):
     while not self.transport:
         waiting()
     # wait for msg
     deferred = WaitingDeferred(msg)
     self.expected_response.insert(0, deferred)
     return deferred
Ejemplo n.º 2
0
 def wait_for(self, msg):
     self.waiting = True
     deferred = self.factory.wait(msg)
     deferred.addCallback(self._finished)
     deferred.addErrback(self._failed)
     while self.waiting:
         waiting()
Ejemplo n.º 3
0
 def check(self, msg, deferred=None):
     while not self.transport:
         waiting()
     # send msg
     if not deferred:
         deferred = defer.Deferred()
     self.expected_response.insert(0, deferred)
     self.transport.write(msg+"\r\n")
     return deferred
Ejemplo n.º 4
0
 def check_next(self, in_msg, out_msg):
     self.waiting = True
     def _assert_msg(msg):
         self.waiting = False
         self.assertEquals(msg, out_msg)
     deferred = self.factory.check(in_msg)
     deferred.addCallback(_assert_msg)
     deferred.addErrback(self._failed)
     while self.waiting:
         waiting()
 def tearDown(self):
     """overrides TestCase method"""
     # close connection
     self.factory.stopTrying()
     self.connector.disconnect()
     self.done = True
     # remove timeout
     try:
         self.timeout.cancel()
         reactor.iterate(0.1)
     except (error.AlreadyCancelled, error.AlreadyCalled):
         pass
     # stop listening
     defered = self.navigator.stopListening()
     if defered:
         self.done = False
         defered.addCallback(self._finished)
         defered.addErrback(self._failed)
         while not self.done:
             waiting()
Ejemplo n.º 6
0
 def tearDown(self):
     """overrides TestCase method"""
     # close connection
     self.factory.stopTrying()
     del self.factory
     self.connector.disconnect()
     # remove timeout
     try:
         self.timeout.cancel()
     except (error.AlreadyCancelled, error.AlreadyCalled):
         print "timeout canceled"
     # stop listening
     deferred = self.navigator.stopListening()
     if deferred:
         self.waiting = True
         deferred.addCallback(self._finished)
         deferred.addErrback(self._failed)
         while self.waiting:
             waiting()
     pendings = reactor.getDelayedCalls()
     for pending in pendings:
         pending.cancel()
     reactor.iterate()
Ejemplo n.º 7
0
 def write(self, msg):
     while not self.transport:
         waiting()
     # send msg
     self.expected_response.insert(0, None)
     self.transport.write(msg+"\r\n")
 def _wait_for(self, msg):
     self.waiting = True
     deferred = self.factory.wait(msg)
     deferred.addCallback(self._stop_waiting)
     while self.waiting:
         waiting()